nfrasser / linkifyjs

JavaScript plugin for finding links in plain-text and converting them to HTML <a> tags.
https://linkify.js.org
MIT License
1.84k stars 184 forks source link

linkifyHtml returning empty string with <!DOCTYPE html> tag #203

Closed sagrawal31 closed 3 years ago

sagrawal31 commented 7 years ago

Given a HTML string with <DOCTYPE html>:

var body = '<!DOCTYPE html> <html lang="en"><head><link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.EFILER.mas_file_sys_parameters.css"/></head><body> <div class="container"> <div class="row" style= "background-color:#ffffff"><div class="col-xs-2 col-sm-2  col-md-2 col-lg-2"></div> <div class="col-xs-8 col-sm-8  col-md-8 col-lg-8 well text-justify" style="background-color:#ffffff"><p>The Income Tax Department has made it easy for taxpayers to link their PAN with Aadhaar.</p><p>It was reported that taxpayers were finding it difficult as their names did not match in both systems (Eg. Names with initials in one and expanded initials in another). Responding to such grievances,the Dept has come out with a simple solution now.</p><p>Just go to <b><a' +
    ' href=\'https://www.incometaxindiaefiling.gov.in/\' style= "color:#3d8b3d">www.incometaxindiaefiling.gov.in</a></b> and click on the link on the left pane -> <b><a href=\'https://www.incometaxindiaefiling.gov.in/e-Filing/Services/LinkAadhaarHome.html\' style= "color:#3d8b3d">Link Aadhaar</a></b>. Provide PAN, Aadhaar no. and ENTER NAME EXACTLY AS GIVEN IN AADHAAR CARD (avoid spelling mistakes) and submit. After verification from UIDAI, the linking will be confirmed. </p><p>In case of any minor mismatch in Aadhaar name provided by you when compared to the actual data in Aadhaar, One Time Password (Aadhaar OTP) will be sent to the mobile registered with Aadhaar which has to be provided. </p><p>In a rare case where Aadhaar name is completely different from name in PAN, then the linking will fail and taxpayer will be prompted to change the name in either Aadhaar or in PAN database.</p><p>To update your PAN details please contact NSDL <b><a href=\'https://www.onlineservices.nsdl.com/paam/endUserRegisterContact.html\' style= "color:#3d8b3d">https://www.onlineservices.nsdl.com/paam/endUserRegisterContact.html</a></b></br> or </br>To update your Aadhaar card details please contact UIDAI at <b><a href=\'https://ssup.uidai.gov.in/web/guest/update\' style= "color:#3d8b3d">https://ssup.uidai.gov.in/web/guest/update</a></b></p><p>This facility is also available after login. Go to Profile settings and choose Aadhaar linking. The details as per PAN are pre-populated. Enter Aadhaar no. and ENTER NAME EXACTLY AS GIVEN IN AADHAAR CARD (avoid spelling mistakes) and submit.</p><p>E-Filing team</p></body></html>'

var result = linkifyHtml(body);
console.log(result);

The output i.e. value in variable result is an empty string. But if we remove the <!DOCTYPE html> from the beginning of the string, linkifyHtml works properly. I tried to search in GitHub issues but didn't found anything useful.

willamesoares commented 5 years ago

Hey!

I implemented this in #272 , although I had to fork the version of simple-html-tokenizer used in here and then implement the new parsing methods in there, so let me know what you all think.

Thanks!

nfrasser commented 3 years ago

Fixed in v3

sagrawal31 commented 3 years ago

Thanks for working on the ticket after 3+ years. I appreciate that.