Commit ebfcece1 authored by Gregor Morrill's avatar Gregor Morrill

Fixes #48

parent 96643a01
......@@ -127,7 +127,9 @@ function mfNamesFromClass($class, $prefix = 'h-') {
$matches = array();
foreach ($classes as $classname) {
if (stristr(' ' . $classname, ' ' . $prefix) !== false) {
$compare_classname = strtolower(' ' . $classname);
$compare_prefix = strtolower(' ' . $prefix);
if (stristr($compare_classname, $compare_prefix) !== false && ($compare_classname != $compare_prefix)) {
$matches[] = ($prefix === 'h-') ? $classname : substr($classname, strlen($prefix));
}
}
......@@ -150,7 +152,8 @@ function nestedMfPropertyNamesFromClass($class) {
foreach (explode(' ', $class) as $classname) {
foreach ($prefixes as $prefix) {
if (stristr(' ' . $classname, $prefix)) {
$compare_classname = strtolower(' ' . $classname);
if (stristr($compare_classname, $prefix) && ($compare_classname != $prefix)) {
$propertyNames = array_merge($propertyNames, mfNamesFromClass($classname, ltrim($prefix)));
}
}
......
......@@ -201,4 +201,17 @@ EOT;
$this->assertNull($mf);
$this->assertContains('jpeg', $curlInfo['content_type']);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/48
*/
public function testIgnoreClassesEndingInHyphen() {
$input = '<span class="h-entry"> <span class="e-">foo</span> </span>';
$parser = new Parser($input);
$output = $parser->parse();
// print_r($output);
$this->assertArrayNotHasKey('0', $output['items'][0]['properties']);
}
}
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