Commit 954a8a00 authored by Ben Roberts's avatar Ben Roberts

fix bug in original parser not checking for sub h-* items

parent cb19d836
......@@ -779,27 +779,35 @@ class Parser {
// Look for nested img @alt
foreach ($this->xpath->query('./img[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
if ($em->getAttribute('alt') != '')
$emNames = mfNamesFromElement($em, 'h-');
if(empty($emNames) && $em->getAttribute('alt') != ''){
throw new Exception($em->getAttribute('alt'));
}
}
// Look for nested area @alt
foreach ($this->xpath->query('./area[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
if ($em->getAttribute('alt') != '')
$emNames = mfNamesFromElement($em, 'h-');
if(empty($emNames) && $em->getAttribute('alt') != ''){
throw new Exception($em->getAttribute('alt'));
}
}
// Look for double nested img @alt
foreach ($this->xpath->query('./*[count(preceding-sibling::*)+count(following-sibling::*)=0]/img[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
if ($em->getAttribute('alt') != '')
$emNames = mfNamesFromElement($em, 'h-');
if(empty($emNames) && $em->getAttribute('alt') != ''){
throw new Exception($em->getAttribute('alt'));
}
}
// Look for double nested img @alt
foreach ($this->xpath->query('./*[count(preceding-sibling::*)+count(following-sibling::*)=0]/area[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
if ($em->getAttribute('alt') != '')
$emNames = mfNamesFromElement($em, 'h-');
if(empty($emNames) && $em->getAttribute('alt') != ''){
throw new Exception($em->getAttribute('alt'));
}
}
throw new Exception($e->nodeValue);
......@@ -837,16 +845,22 @@ class Parser {
if ($e->tagName == 'a' or $e->tagName == 'area')
$url = $e->getAttribute('href');
// Look for nested img @src
// Look for nested a @href
foreach ($this->xpath->query('./a[count(preceding-sibling::a)+count(following-sibling::a)=0]', $e) as $em) {
$url = $em->getAttribute('href');
break;
$emNames = mfNamesFromElement($em, 'h-');
if(empty($emNames)){
$url = $em->getAttribute('href');
break;
}
}
// Look for nested area @src
foreach ($this->xpath->query('./area[count(preceding-sibling::area)+count(following-sibling::area)=0]', $e) as $em) {
$url = $em->getAttribute('href');
break;
$emNames = mfNamesFromElement($em, 'h-');
if(empty($emNames)){
$url = $em->getAttribute('href');
break;
}
}
if (!empty($url))
......
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