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

FIRE: anchor tags without an href lead to an error #239

Open
PurpleMagick opened this issue Jul 4, 2024 · 1 comment
Open

FIRE: anchor tags without an href lead to an error #239

PurpleMagick opened this issue Jul 4, 2024 · 1 comment

Comments

@PurpleMagick
Copy link

PurpleMagick commented Jul 4, 2024

If a post has an anchor tag without any href, for example <a></a>, then there is an error in pointRelativeURLsToSourceSESite().

Code with reproduced here for ease of access:

reportBody.find('a').each(function () {
      const $this = $(this);
      let href = $this.attr('href');
      if (!/^(?:[a-z]+:)?\/\//.test(href)) {
        // It's not a fully qualified or protocol-relative link.
        if (href.startsWith('/')) {

href.startsWith('/') throws an error because href is undefined.

Example report with an anchor that is missing an href: https://m.erwaysoftware.com/posts/uid/stackoverflow/78706588

Chat link for the report: https://chat.stackexchange.com/transcript/message/65904497#65904497

@makyen
Copy link
Contributor

makyen commented Jul 4, 2024

Thanks for the report. Yep,

let href = $this.attr('href');

should be

let href = $this.attr('href') || '';

This issue also affects the preview tab on MS (FIRE and MS share this code). I've already pushed code to MS, but have not, yet, been able to deploy it.

Interestingly, this error occurs in this post due to an error in parsing caused by SmokeDetector providing MS with a processed version of the HTML with all the HTML entities converted to characters. This results in the "<a>" that's supposed to be actual text (i.e., actually &lt;a&gt;) being seen as a valid <a> tag. Given the processed nature of the text supplied to MS, there is, unfortunately, no way to accurately recover the real text in 100% of all cases.

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

No branches or pull requests

2 participants