Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix loading of a href element #24

Closed
wants to merge 1 commit into from

Conversation

vavrecan
Copy link

it can happen, that this function will fail in case of etc or or other issues. i would say it is a good idea to do additional error checking so that $a->getAttribute will not throw exception when a is null.

it can happen, that this function will fail in case of <abrr> <a></a> etc or or other issues. i would say it is a good idea to do additional error checking so that $a->getAttribute will not throw exception when a is null.
@Sommerregen
Copy link
Owner

@vavrecan Can you give me an example, when such a thing happens?

@vavrecan
Copy link
Author

vavrecan commented Jun 22, 2018

Iirc If tag in source is <abbr> </a> or so

Copy link
Owner

@Sommerregen Sommerregen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vavrecan,

I think what you actually mean is:

$a = $dom->getElementsByTagName('a');
if ($a->length == 0) {
  return $match[0];
}
$a = $a->item(0);

as there is no check yet in the code for "emptyness" in the code. However, If found a bug with <abbr>: obviously the regex is wrong and has to be <a(?:\s[^>]*)?>.*?</a>.

Can you check my changes in the develop branch?

@Sommerregen Sommerregen added the bug label Jul 9, 2018
Sommerregen added a commit that referenced this pull request Jul 9, 2018
@Sommerregen
Copy link
Owner

Merged. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants