diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 7ff2201..2c1c08b 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -127,6 +127,7 @@ function unicodeTrim($str) { function mfNamesFromClass($class, $prefix='h-') { $class = str_replace(array(' ', ' ', "\n"), ' ', $class); $classes = explode(' ', $class); + $classes = preg_grep('#^[a-z\-]+$#', $classes); $matches = array(); foreach ($classes as $classname) { diff --git a/tests/Mf2/ParserTest.php b/tests/Mf2/ParserTest.php index 30e59d9..fa892d7 100644 --- a/tests/Mf2/ParserTest.php +++ b/tests/Mf2/ParserTest.php @@ -422,4 +422,82 @@ public function testWhitespaceBetweenElements() { $this->assertContains('h-entry', $output['items'][0]['type']); $this->assertNotContains('attendingHomebrew', $output['items'][0]['properties']['name'][0]); } + + + /** + * @see http://www.kevinmarks.com/twitterutils.html + */ + public function testCamelCaseClassNames() { + $input = << + +
+
+ + +
+

I wish people would stop using u- as a prefix for utility classes in CSS. Use util- instead. You're messing with my microformats.

+ + + + + + +
+
+
+ +EOT; + + $output = Mf2\parse($input); + + $this->assertArrayNotHasKey('linkBlend', $output['items'][0]['properties']); + $this->assertArrayNotHasKey('hiddenInNarrowEnv', $output['items'][0]['properties']); + $this->assertArrayNotHasKey('floatRight', $output['items'][0]['properties']); + } + + + public function testClassNameNumbers() { + $input = '

Test

'; + $output = Mf2\parse($input); + + $this->assertArrayNotHasKey('column1', $output['items'][0]['properties']); + } + }