Commit 7a4357a8 authored by Gregor Morrill's avatar Gregor Morrill

Added failing test and fix for #89.

parent d653341e
......@@ -409,14 +409,14 @@ class Parser {
if (in_array(strtolower($el->tagName), $excludeTags)) {
return $out;
} else if ($el->tagName == 'img') {
if ($el->getAttribute('alt') !== '') {
if ($el->hasAttribute('alt')) {
return $el->getAttribute('alt');
} else if (!$implied && $el->getAttribute('src') !== '') {
} else if (!$implied && $el->hasAttribute('src')) {
return $this->resolveUrl($el->getAttribute('src'));
}
} else if ($el->tagName == 'area' and $el->getAttribute('alt') !== '') {
} else if ($el->tagName == 'area' and $el->hasAttribute('alt')) {
return $el->getAttribute('alt');
} else if ($el->tagName == 'abbr' and $el->getAttribute('title') !== '') {
} else if ($el->tagName == 'abbr' and $el->hasAttribute('title')) {
return $el->getAttribute('title');
}
}
......
......@@ -115,4 +115,15 @@ EOT;
$this->assertEquals('Street Name 9' . "\n" . '12345 NY, USA', $result['items'][0]['properties']['name'][0]);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/89
*/
public function testEmptyAlt() {
$input = '<div class="p-author h-card"><a href="/" class="p-org p-name"><img class="u-logo" src="/static/logo.jpg" alt="" />mention.tech</a></div>';
$result = Mf2\parse($input);
$this->assertEquals('mention.tech', $result['items'][0]['properties']['org'][0]);
$this->assertEquals('mention.tech', $result['items'][0]['properties']['name'][0]);
}
}
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