Commit f40d35e9 authored by webchick's avatar webchick

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

parent 66b964dd
......@@ -957,16 +957,16 @@
},
{
"name": "masterminds/html5",
"version": "2.1.0",
"version": "2.1.2",
"source": {
"type": "git",
"url": "https://github.com/Masterminds/html5-php.git",
"reference": "a10f8d392e1aad0b500f7b440c8f0d3bc9189704"
"reference": "8f782e0f01a6e33a319bdc8f6de9cfd6569979a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/a10f8d392e1aad0b500f7b440c8f0d3bc9189704",
"reference": "a10f8d392e1aad0b500f7b440c8f0d3bc9189704",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/8f782e0f01a6e33a319bdc8f6de9cfd6569979a4",
"reference": "8f782e0f01a6e33a319bdc8f6de9cfd6569979a4",
"shasum": ""
},
"require": {
......@@ -1018,7 +1018,7 @@
"serializer",
"xml"
],
"time": "2015-02-09 16:26:00"
"time": "2015-06-07 08:43:18"
},
{
"name": "mikey179/vfsStream",
......
......@@ -351,7 +351,7 @@ private function findFileWithExtension($class, $ext)
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
if (0 === strpos($class, $prefix)) {
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;
}
}
......@@ -361,7 +361,7 @@ private function findFileWithExtension($class, $ext)
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
......@@ -380,7 +380,7 @@ private function findFileWithExtension($class, $ext)
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
......@@ -390,7 +390,7 @@ private function findFileWithExtension($class, $ext)
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
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 @@
"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",
"version": "1.3.0",
......@@ -3483,5 +3416,72 @@
"keywords": [
"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:
- 5.5
- 5.6
- hhvm
- nightly
notifications:
irc: "irc.freenode.net#masterminds"
before_script:
- composer self-update
- composer install --dev
- composer install
script:
- mkdir -p build/logs
......
......@@ -101,7 +101,7 @@ The following options are supported:
* `disable_html_ns` (boolean): Prevents the parser from automatically
assigning the HTML5 namespace to the DOM document. This is for
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.
* `implicit_namespaces` (array): An assoc array of namespaces that should be
used by the parser. Name is tag prefix, value is NS URI.
......
# 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)
- #74: Added `disable_html_ns` and `target_doc` dom parsing options
......
......@@ -1065,8 +1065,14 @@ protected function decodeCharacterReference($inAttribute = false)
// [a-zA-Z0-9]+;
$cname = $this->scanner->getAsciiAlpha();
$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) {
$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
'nodeName'=>'img', 'nodeName'=>array('img', 'a'),
'attrName'=>'alt', 'attrName'=>array('title', 'alt'),
'prefixes'=>['xh'=>'http://www.w3.org/1999/xhtml'),
'xpath' => "@checked[../../xh:input[@type='radio' or @type='checkbox']]",
),
*/
array(
'nodeNamespace'=>'http://www.w3.org/1999/xhtml',
'attrName'=>array('alt', 'title'),
'nodeNamespace' => 'http://www.w3.org/1999/xhtml',
'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>';
......@@ -328,7 +397,7 @@ protected function nonBooleanAttribute(\DOMAttr $attr)
$xp->registerNamespace($nsPrefix, $ns);
}
}
if(!$xp->query($rule['xpath'], $attr->ownerElement)->length){
if(!$xp->evaluate($rule['xpath'], $attr)){
continue;
}
}
......
......@@ -376,6 +376,9 @@ public function testEntities()
$res = $this->cycleFragment('<a>Apples &amp; bananas.</a>');
$this->assertRegExp('|Apples &amp; bananas.|', $res);
$res = $this->cycleFragment('<p>R&D</p>');
$this->assertRegExp('|R&amp;D|', $res);
}
public function testComment()
......
<?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";
$errors = UTF8Utils::checkForIllegalCodepoints($data);
$this->assertContains('null-character', $errors);
}
}
\ No newline at end of file
......@@ -460,8 +460,10 @@ public function booleanAttributes()
array('<input type="radio" readonly>'),
array('<input type="radio" checked disabled>'),
array('<input type="checkbox" checked disabled>'),
array('<input type="radio" value="" checked disabled>'),
array('<div data-value=""></div>'),
array('<select disabled></select>'),
array('<div ng-app>foo</div>'),
array('<div ng-app></div>'),
array('<script defer></script>'),
);
}
......@@ -482,7 +484,11 @@ public function testBooleanAttrs($html)
$m->invoke($r, $node);
$content = stream_get_contents($stream, - 1, 0);
$this->assertContains($content, $html);
$html = preg_replace('~<[a-z]+(.*)></[a-z]+>~', '\1', $html);
$html = preg_replace('~<[a-z]+(.*)/?>~', '\1', $html);
$this->assertEquals($content, $html);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment