Browse Source

better error when no link is found in microformats

for https://github.com/aaronpk/webmention.io/issues/150
pull/97/head v1.10.4
Aaron Parecki 4 years ago
parent
commit
e8e20fc27e
No known key found for this signature in database GPG Key ID: 276C2817346D6056
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      lib/XRay/Parser.php

+ 4
- 2
lib/XRay/Parser.php View File

@ -25,14 +25,16 @@ class Parser {
// Ignore this check for any non-HTML documents since this will be uncommon anyway // Ignore this check for any non-HTML documents since this will be uncommon anyway
$found = false; $found = false;
} }
$error_description = 'The source document does not have a link to the target URL';
} else { } else {
$found = $this->_findLinkInTree($opts['target'], $document['data']); $found = $this->_findLinkInTree($opts['target'], $document['data']);
$error_description = 'The Microformats at the source URL do not contain a link to the target URL. Check the source URL in a Microformats parser such as php.microformats.io';
} }
if(!$found) { if(!$found) {
return [ return [
'error' => 'no_link_found', 'error' => 'no_link_found',
'error_description' => 'The source document does not have a link to the target URL',
'error_description' => $error_description,
'code' => isset($document['code']) ? $document['code'] : 200, 'code' => isset($document['code']) ? $document['code'] : 200,
'url' => $document['url'], 'url' => $document['url'],
'debug' => $document['data'] 'debug' => $document['data']
@ -41,7 +43,7 @@ class Parser {
} }
// If the HTML parser couldn't parse the page it returns the full HTML for checking the target above, // If the HTML parser couldn't parse the page it returns the full HTML for checking the target above,
// but we don't want to return that in the out put so remove it here
// but we don't want to return that in the output so remove it here
unset($document['html']); unset($document['html']);
return $document; return $document;

Loading…
Cancel
Save