Autolinker.js icon indicating copy to clipboard operation
Autolinker.js copied to clipboard

Link parsing issue

Open wreiske opened this issue 5 years ago • 4 comments

I wasn't exactly sure what to title this... There's an issue with autolinker when it thinks there is a phone number, or something, inside of a link. It seems to happen only if there is something that looks like a phone number...twice?

const autolinker = require('autolinker');
var link = 'https://test.com/testing/dp/1-2605551234-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true';

console.log("link:", link);
console.log("autolinker:", autolinker.link(link))

Returns:

link: https://test.com/testing/dp/1-2605551234-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true

autolinker: <a href="https://test.com/testing/dp/1-2605551234-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true" target="_blank" rel="noopener noreferrer">test.com/testing/dp/1-2605551234-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true</a>2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true<a href="tel:25639174730" target="_blank" rel="noopener noreferrer">2563917-4730</a>-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true

Notice the second HREF mid-link, and the A tag ending early.

If you remove the first phone number, it parses fine.

link: https://test.com/testing/dp/1-nonumber-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true

autolinker: <a href="https://test.com/testing/dp/1-nonumber-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true" target="_blank" rel="noopener noreferrer">test.com/testing/dp/1-nonumber-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true</a>

I found this from pasting an Amazon link into a rocket.chat conversation. The amazon link parsed weird. https://github.com/RocketChat/Rocket.Chat/issues/13731

image

At first, I thought it might be an issue with Rocket.Chat, but I tracked it down to this autolinker library.

Also, this affects the truncate display as well. image

Test for yourself at http://greg-jacobs.com/Autolinker.js/examples/index.html

Paste in: https://test.com/testing/dp/1-nonumber-test?refId=8F6FS9NHT1Z61S6Z1DFQ2563917-4730-11e9-9fed-6f308a1afb98&test_0=true&test_1=true&test_2=true

wreiske avatar Mar 22 '19 05:03 wreiske

Wow, interesting, thanks for the report! Will look into this

gregjacobs avatar Mar 22 '19 11:03 gregjacobs

Also https://guest:[email protected]/barcode.png?s=qr&c=https%3A%2F%2Fguest%3A7FLiz996Xy2wkVTS%40new.cwinfo.fi%2F this link doesnt work in Rocket Chat

THIS IS JUST EXAMPLE NOT REAL PASSWORD INTENTIONALLY

cwchristerw avatar May 12 '19 01:05 cwchristerw

Any updates to this? 👀

wreiske avatar Aug 20 '19 22:08 wreiske

This is still present in 3.14.3

image

wreiske avatar May 10 '21 20:05 wreiske