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

An anchor (<a/>) without a href attribute causes a crash #11

Closed
AMKohn opened this issue Oct 1, 2013 · 5 comments
Closed

An anchor (<a/>) without a href attribute causes a crash #11

AMKohn opened this issue Oct 1, 2013 · 5 comments
Assignees
Labels

Comments

@AMKohn
Copy link
Contributor

AMKohn commented Oct 1, 2013

Hi,

I have started developing with html-to-text and discovered that it expects every anchor to have a href and crashes when it doesn't find one.

Changing line 25 in formatter.js from

return elem.attribs.href.replace(/^mailto\:/, '');

to

if (elem.attribs && elem.attribs.href) {
    return elem.attribs.href.replace(/^mailto\:/, '');
}
else {
    return helper.wordwrap(helper.decodeHTMLEntities(_s.strip(elem.raw)), options.wordwrap);
}

fixes this.

Thank you!

@ghost ghost assigned mlegenhausen Oct 2, 2013
@mlegenhausen
Copy link
Member

Thanks for the bug report.

@AMKohn
Copy link
Contributor Author

AMKohn commented Oct 2, 2013

Thank you for the package!

thanh-nguyen added a commit to thanh-nguyen/node-html-to-text that referenced this issue Dec 19, 2013
thanh-nguyen added a commit to thanh-nguyen/node-html-to-text that referenced this issue Dec 19, 2013
@niftylettuce
Copy link

Why hasn't this ever been fixed yet? At least give collaborator status to another person on this project so they can help maintain. 👍

@mlegenhausen
Copy link
Member

Seems to fixed by #21. Closed for now.

@danmactough
Copy link
Contributor

Seems to fixed by #21. Closed for now.

Wow. Bonus!

MUDev1994 pushed a commit to MUDev1994/node-html-to-text that referenced this issue May 26, 2023
MUDev1994 pushed a commit to MUDev1994/node-html-to-text that referenced this issue May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants