From 96312b9fedb4840a37801920cdb119a4526dcc3b Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 3 Oct 2015 15:07:28 -0700 Subject: [PATCH] Decode percent-encoded characters in domain so that they behave consistently across browsers. #486 --- src/Linkification/Linkify.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 6851738f2..91eab942e 100755 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -127,6 +127,12 @@ Linkify = 'http://' ) + text + # Decode percent-encoded characters in domain so that they behave consistently across browsers. + if encodedDomain = text.match /^(https?:\/\/[^/]*%[0-9a-f]{2})(.*)$/i + text = encodedDomain[1].replace(/%([0-9a-f]{2})/ig, (x, y) -> + if y is '25' then x else String.fromCharCode(parseInt y, 16) + ) + encodedDomain[2] + a = $.el 'a', className: 'linkify' rel: 'nofollow noreferrer'