Commit f40d35e9 authored by webchick's avatar webchick

Issue #2400407 by hussainweb: Update masterminds/html5 to latest release

parent 66b964dd
...@@ -957,16 +957,16 @@ ...@@ -957,16 +957,16 @@
}, },
{ {
"name": "masterminds/html5", "name": "masterminds/html5",
"version": "2.1.0", "version": "2.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Masterminds/html5-php.git", "url": "https://github.com/Masterminds/html5-php.git",
"reference": "a10f8d392e1aad0b500f7b440c8f0d3bc9189704" "reference": "8f782e0f01a6e33a319bdc8f6de9cfd6569979a4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/a10f8d392e1aad0b500f7b440c8f0d3bc9189704", "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/8f782e0f01a6e33a319bdc8f6de9cfd6569979a4",
"reference": "a10f8d392e1aad0b500f7b440c8f0d3bc9189704", "reference": "8f782e0f01a6e33a319bdc8f6de9cfd6569979a4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1018,7 +1018,7 @@ ...@@ -1018,7 +1018,7 @@
"serializer", "serializer",
"xml" "xml"
], ],
"time": "2015-02-09 16:26:00" "time": "2015-06-07 08:43:18"
}, },
{ {
"name": "mikey179/vfsStream", "name": "mikey179/vfsStream",
......
...@@ -351,7 +351,7 @@ private function findFileWithExtension($class, $ext) ...@@ -351,7 +351,7 @@ private function findFileWithExtension($class, $ext)
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
if (0 === strpos($class, $prefix)) { if (0 === strpos($class, $prefix)) {
foreach ($this->prefixDirsPsr4[$prefix] as $dir) { foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file; return $file;
} }
} }
...@@ -361,7 +361,7 @@ private function findFileWithExtension($class, $ext) ...@@ -361,7 +361,7 @@ private function findFileWithExtension($class, $ext)
// PSR-4 fallback dirs // PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) { foreach ($this->fallbackDirsPsr4 as $dir) {
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file; return $file;
} }
} }
...@@ -380,7 +380,7 @@ private function findFileWithExtension($class, $ext) ...@@ -380,7 +380,7 @@ private function findFileWithExtension($class, $ext)
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) { if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file; return $file;
} }
} }
...@@ -390,7 +390,7 @@ private function findFileWithExtension($class, $ext) ...@@ -390,7 +390,7 @@ private function findFileWithExtension($class, $ext)
// PSR-0 fallback dirs // PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) { foreach ($this->fallbackDirsPsr0 as $dir) {
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file; return $file;
} }
} }
......
<?php
// include_paths.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$vendorDir . '/phpunit/php-text-template',
);
...@@ -265,73 +265,6 @@ ...@@ -265,73 +265,6 @@
"testing" "testing"
] ]
}, },
{
"name": "masterminds/html5",
"version": "2.1.0",
"version_normalized": "2.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/Masterminds/html5-php.git",
"reference": "a10f8d392e1aad0b500f7b440c8f0d3bc9189704"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/a10f8d392e1aad0b500f7b440c8f0d3bc9189704",
"reference": "a10f8d392e1aad0b500f7b440c8f0d3bc9189704",
"shasum": ""
},
"require": {
"ext-libxml": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"sami/sami": "~2.0",
"satooshi/php-coveralls": "0.6.*"
},
"time": "2015-02-09 16:26:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Masterminds\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Matt Butcher",
"email": "technosophos@gmail.com"
},
{
"name": "Asmir Mustafic",
"email": "goetas@gmail.com"
},
{
"name": "Matt Farina",
"email": "matt@mattfarina.com"
}
],
"description": "An HTML5 parser and serializer.",
"homepage": "http://masterminds.github.io/html5-php",
"keywords": [
"HTML5",
"dom",
"html",
"parser",
"querypath",
"serializer",
"xml"
]
},
{ {
"name": "sebastian/diff", "name": "sebastian/diff",
"version": "1.3.0", "version": "1.3.0",
...@@ -3483,5 +3416,72 @@ ...@@ -3483,5 +3416,72 @@
"keywords": [ "keywords": [
"stack" "stack"
] ]
},
{
"name": "masterminds/html5",
"version": "2.1.2",
"version_normalized": "2.1.2.0",
"source": {
"type": "git",
"url": "https://github.com/Masterminds/html5-php.git",
"reference": "8f782e0f01a6e33a319bdc8f6de9cfd6569979a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/8f782e0f01a6e33a319bdc8f6de9cfd6569979a4",
"reference": "8f782e0f01a6e33a319bdc8f6de9cfd6569979a4",
"shasum": ""
},
"require": {
"ext-libxml": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"sami/sami": "~2.0",
"satooshi/php-coveralls": "0.6.*"
},
"time": "2015-06-07 08:43:18",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Masterminds\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Matt Butcher",
"email": "technosophos@gmail.com"
},
{
"name": "Asmir Mustafic",
"email": "goetas@gmail.com"
},
{
"name": "Matt Farina",
"email": "matt@mattfarina.com"
}
],
"description": "An HTML5 parser and serializer.",
"homepage": "http://masterminds.github.io/html5-php",
"keywords": [
"HTML5",
"dom",
"html",
"parser",
"querypath",
"serializer",
"xml"
]
} }
] ]
...@@ -12,13 +12,14 @@ php: ...@@ -12,13 +12,14 @@ php:
- 5.5 - 5.5
- 5.6 - 5.6
- hhvm - hhvm
- nightly
notifications: notifications:
irc: "irc.freenode.net#masterminds" irc: "irc.freenode.net#masterminds"
before_script: before_script:
- composer self-update - composer self-update
- composer install --dev - composer install
script: script:
- mkdir -p build/logs - mkdir -p build/logs
......
...@@ -7,5 +7,5 @@ Kukhar Vasily [ngreduce] <ngreduce@gmail.com> (contributor) ...@@ -7,5 +7,5 @@ Kukhar Vasily [ngreduce] <ngreduce@gmail.com> (contributor)
Rune Christensen [MrElectronic] <mrelectronic@example.com> (contributor) Rune Christensen [MrElectronic] <mrelectronic@example.com> (contributor)
Mišo Belica [miso-belica] <miso-belica@example.com> (contributor) Mišo Belica [miso-belica] <miso-belica@example.com> (contributor)
Asmir Mustafic [goetas] <goetas@example.com> (contributor) Asmir Mustafic [goetas] <goetas@example.com> (contributor)
KITAITI Makoto [KitaitiMakoto] <KitaitiMakoto@example.com> (contributor) KITAITI Makoto [KitaitiMakoto] <KitaitiMakoto@example.com> (contributor)
Jacob Floyd [cognifloyd] <cognifloyd@gmail.com> (contributor) Jacob Floyd [cognifloyd] <cognifloyd@gmail.com> (contributor)
...@@ -7,8 +7,8 @@ Matt Farina - matt@mattfarina.com ...@@ -7,8 +7,8 @@ Matt Farina - matt@mattfarina.com
Asmir Mustafic - goetas@gmail.com Asmir Mustafic - goetas@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so, the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: subject to the following conditions:
...@@ -49,8 +49,8 @@ The Mozilla Foundation (contributions from Henri Sivonen since 2008) ...@@ -49,8 +49,8 @@ The Mozilla Foundation (contributions from Henri Sivonen since 2008)
David Flanagan (Mozilla) - dflanagan@mozilla.com David Flanagan (Mozilla) - dflanagan@mozilla.com
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so, the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: subject to the following conditions:
......
...@@ -36,7 +36,7 @@ install. ...@@ -36,7 +36,7 @@ install.
## Basic Usage ## Basic Usage
HTML5-PHP has a high-level API and a low-level API. HTML5-PHP has a high-level API and a low-level API.
Here is how you use the high-level `HTML5` library API: Here is how you use the high-level `HTML5` library API:
...@@ -101,7 +101,7 @@ The following options are supported: ...@@ -101,7 +101,7 @@ The following options are supported:
* `disable_html_ns` (boolean): Prevents the parser from automatically * `disable_html_ns` (boolean): Prevents the parser from automatically
assigning the HTML5 namespace to the DOM document. This is for assigning the HTML5 namespace to the DOM document. This is for
non-namespace aware DOM tools. non-namespace aware DOM tools.
* `target_doc` (\DOMDocument): A DOM document that will be used as the * `target_document` (\DOMDocument): A DOM document that will be used as the
destination for the parsed nodes. destination for the parsed nodes.
* `implicit_namespaces` (array): An assoc array of namespaces that should be * `implicit_namespaces` (array): An assoc array of namespaces that should be
used by the parser. Name is tag prefix, value is NS URI. used by the parser. Name is tag prefix, value is NS URI.
...@@ -144,14 +144,14 @@ The serializer is broken into three parts: ...@@ -144,14 +144,14 @@ The serializer is broken into three parts:
- The `OutputRules` contain the rules to turn DOM elements into strings. The - The `OutputRules` contain the rules to turn DOM elements into strings. The
rules are an implementation of the interface `RulesInterface` allowing for rules are an implementation of the interface `RulesInterface` allowing for
different rule sets to be used. different rule sets to be used.
- The `Traverser`, which is a special-purpose tree walker. It visits - The `Traverser`, which is a special-purpose tree walker. It visits
each node node in the tree and uses the `OutputRules` to transform the node each node node in the tree and uses the `OutputRules` to transform the node
into a string. into a string.
- `HTML5` manages the `Traverser` and stores the resultant data - `HTML5` manages the `Traverser` and stores the resultant data
in the correct place. in the correct place.
The serializer (`save()`, `saveHTML()`) follows the The serializer (`save()`, `saveHTML()`) follows the
[section 8.9 of the HTML 5.0 spec](http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#serializing-html-fragments). [section 8.9 of the HTML 5.0 spec](http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#serializing-html-fragments).
So tags are serialized according to these rules: So tags are serialized according to these rules:
...@@ -166,8 +166,8 @@ issues known issues that are not presently on the roadmap: ...@@ -166,8 +166,8 @@ issues known issues that are not presently on the roadmap:
- Namespaces: HTML5 only [supports a selected list of namespaces](http://www.w3.org/TR/html5/infrastructure.html#namespaces) - Namespaces: HTML5 only [supports a selected list of namespaces](http://www.w3.org/TR/html5/infrastructure.html#namespaces)
and they do not operate in the same way as XML namespaces. A `:` has no special and they do not operate in the same way as XML namespaces. A `:` has no special
meaning. meaning.
By default the parser does not support XML style namespaces via `:`; By default the parser does not support XML style namespaces via `:`;
to enable the XML namespaces see the [XML Namespaces section](#xml-namespaces) to enable the XML namespaces see the [XML Namespaces section](#xml-namespaces)
- Scripts: This parser does not contain a JavaScript or a CSS - Scripts: This parser does not contain a JavaScript or a CSS
interpreter. While one may be supplied, not all features will be interpreter. While one may be supplied, not all features will be
...@@ -184,13 +184,13 @@ issues known issues that are not presently on the roadmap: ...@@ -184,13 +184,13 @@ issues known issues that are not presently on the roadmap:
* Per the spec, many legacy tags are admitted and correctly handled, * Per the spec, many legacy tags are admitted and correctly handled,
even though they are technically not part of HTML5. even though they are technically not part of HTML5.
- Attribute names and values: Due to the implementation details of the - Attribute names and values: Due to the implementation details of the
PHP implementation of DOM, attribute names that do not follow the PHP implementation of DOM, attribute names that do not follow the
XML 1.0 standard are not inserted into the DOM. (Effectively, they XML 1.0 standard are not inserted into the DOM. (Effectively, they
are ignored.) If you've got a clever fix for this, jump in! are ignored.) If you've got a clever fix for this, jump in!
- Processor Instructions: The HTML5 spec does not allow processor - Processor Instructions: The HTML5 spec does not allow processor
instructions. We do. Since this is a server-side library, we think instructions. We do. Since this is a server-side library, we think
this is useful. And that means, dear reader, that in some cases you this is useful. And that means, dear reader, that in some cases you
can parse the HTML from a mixed PHP/HTML document. This, however, can parse the HTML from a mixed PHP/HTML document. This, however,
is an incidental feature, not a core feature. is an incidental feature, not a core feature.
- HTML manifests: Unsupported. - HTML manifests: Unsupported.
- PLAINTEXT: Unsupported. - PLAINTEXT: Unsupported.
......
# Release Notes # Release Notes
2.1.2 (2015-06-07)
- #82: Support for PHP7
- #84: Improved boolean attribute handling
2.1.1 (2015-03-23)
- #78: Fixes bug where unmatched entity like string drops everything after &.
2.1.0 (2015-02-01) 2.1.0 (2015-02-01)
- #74: Added `disable_html_ns` and `target_doc` dom parsing options - #74: Added `disable_html_ns` and `target_doc` dom parsing options
......
...@@ -2,19 +2,19 @@ From 1.x to 2.x ...@@ -2,19 +2,19 @@ From 1.x to 2.x
================= =================
- All classes uses `Masterminds` namespace. - All classes uses `Masterminds` namespace.
- All public static methods has been removed from `HTML5` class and the general API to access the HTML5 functionalities has changed. - All public static methods has been removed from `HTML5` class and the general API to access the HTML5 functionalities has changed.
Before: Before:
$dom = \HTML5::loadHTML('<html>....'); $dom = \HTML5::loadHTML('<html>....');
\HTML5::saveHTML($dom); \HTML5::saveHTML($dom);
After: After:
use Masterminds\HTML5; use Masterminds\HTML5;
$html5 = new HTML5(); $html5 = new HTML5();
$dom = $html5->loadHTML('<html>....'); $dom = $html5->loadHTML('<html>....');
echo $html5->saveHTML($dom); echo $html5->saveHTML($dom);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<file>src/HTML5/Parser/InputStream.php</file> <file>src/HTML5/Parser/InputStream.php</file>
<file>src/HTML5/Serializer/RulesInterface.php</file> <file>src/HTML5/Serializer/RulesInterface.php</file>
<file>src/HTML5/Entities.php</file> <file>src/HTML5/Entities.php</file>
<file>src/HTML5/Serializer/HTML5Entities.php</file> <file>src/HTML5/Serializer/HTML5Entities.php</file>
</blacklist> </blacklist>
</filter> </filter>
<logging> <logging>
......
...@@ -1065,8 +1065,14 @@ protected function decodeCharacterReference($inAttribute = false) ...@@ -1065,8 +1065,14 @@ protected function decodeCharacterReference($inAttribute = false)
// [a-zA-Z0-9]+; // [a-zA-Z0-9]+;
$cname = $this->scanner->getAsciiAlpha(); $cname = $this->scanner->getAsciiAlpha();
$entity = CharacterReference::lookupName($cname); $entity = CharacterReference::lookupName($cname);
// When no entity is found provide the name of the unmatched string
// and continue on as the & is not part of an entity. The & will
// be converted to &amp; elsewhere.
if ($entity == null) { if ($entity == null) {
$this->parseError("No match in entity table for '%s'", $entity); $this->parseError("No match in entity table for '%s'", $cname);
$this->scanner->unconsume($this->scanner->position() - $start);
return '&';
} }
} }
......
...@@ -73,17 +73,86 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface ...@@ -73,17 +73,86 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
'nodeName'=>'img', 'nodeName'=>array('img', 'a'), 'nodeName'=>'img', 'nodeName'=>array('img', 'a'),
'attrName'=>'alt', 'attrName'=>array('title', 'alt'), 'attrName'=>'alt', 'attrName'=>array('title', 'alt'),
'prefixes'=>['xh'=>'http://www.w3.org/1999/xhtml'),
'xpath' => "@checked[../../xh:input[@type='radio' or @type='checkbox']]",
), ),
*/ */
array( array(
'nodeNamespace'=>'http://www.w3.org/1999/xhtml', 'nodeNamespace' => 'http://www.w3.org/1999/xhtml',
'attrName'=>array('alt', 'title'), 'attrName' => array('href',
'hreflang',
'http-equiv',
'icon',
'id',
'keytype',
'kind',
'label',
'lang',
'language',
'list',
'maxlength',
'media',
'method',
'name',
'placeholder',
'rel',
'rows',
'rowspan',
'sandbox',
'spellcheck',
'scope',
'seamless',
'shape',
'size',
'sizes',
'span',
'src',
'srcdoc',
'srclang',
'srcset',
'start',
'step',
'style',
'summary',
'tabindex',
'target',
'title',
'type',
'value',
'width',
'border',
'charset',
'cite',
'class',
'code',
'codebase',
'color',
'cols',
'colspan',
'content',
'coords',
'data',
'datetime',
'default',
'dir',
'dirname',
'enctype',
'for',
'form',
'formaction',
'headers',
'height',
'accept',
'accept-charset',
'accesskey',
'action',
'align',
'alt',
'bgcolor',
),
),
array(
'nodeNamespace' => 'http://www.w3.org/1999/xhtml',
'xpath' => 'starts-with(local-name(), \'data-\')',
), ),
); );
const DOCTYPE = '<!DOCTYPE html>'; const DOCTYPE = '<!DOCTYPE html>';
...@@ -328,7 +397,7 @@ protected function nonBooleanAttribute(\DOMAttr $attr) ...@@ -328,7 +397,7 @@ protected function nonBooleanAttribute(\DOMAttr $attr)
$xp->registerNamespace($nsPrefix, $ns); $xp->registerNamespace($nsPrefix, $ns);
} }
} }
if(!$xp->query($rule['xpath'], $attr->ownerElement)->length){ if(!$xp->evaluate($rule['xpath'], $attr)){
continue; continue;
} }
} }
......
...@@ -376,6 +376,9 @@ public function testEntities() ...@@ -376,6 +376,9 @@ public function testEntities()
$res = $this->cycleFragment('<a>Apples &amp; bananas.</a>'); $res = $this->cycleFragment('<a>Apples &amp; bananas.</a>');
$this->assertRegExp('|Apples &amp; bananas.|', $res); $this->assertRegExp('|Apples &amp; bananas.|', $res);
$res = $this->cycleFragment('<p>R&D</p>');
$this->assertRegExp('|R&amp;D|', $res);
} }
public function testComment() public function testComment()
......
...@@ -100,7 +100,7 @@ public function testDocumentWithATargetDocument() ...@@ -100,7 +100,7 @@ public function testDocumentWithATargetDocument()
$this->assertSame($doc, $targetDom); $this->assertSame($doc, $targetDom);
$this->assertEquals('html', $doc->documentElement->tagName); $this->assertEquals('html', $doc->documentElement->tagName);
} }
public function testDocumentFakeAttrAbsence() public function testDocumentFakeAttrAbsence()
{ {
$html = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><body>foo</body></html>"; $html = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><body>foo</body></html>";
......
<?php
namespace Masterminds\HTML5\Tests\Parser;
use Masterminds\HTML5\Parser\UTF8Utils;
class UTF8UtilsTest extends \Masterminds\HTML5\Tests\TestCase
{
public function testConvertToUTF8() {
$out = UTF8Utils::convertToUTF8('éàa', 'ISO-8859-1');
$this->assertEquals('éàa', $out);
}
/**
* @todo add tests for invalid codepoints
*/
public function testCheckForIllegalCodepoints() {
$smoke = "Smoke test";
$err = UTF8Utils::checkForIllegalCodepoints($smoke);
$this->assertEmpty($err);
$data = "Foo Bar \0 Baz";