diff --git a/Changelog.md b/Changelog.md index 6aa69902f..cfba5e566 100644 --- a/Changelog.md +++ b/Changelog.md @@ -32,6 +32,7 @@ * OpenGraph: don't make description into links [#4492](https://github.com/diaspora/diaspora/issues/4492) * Don't cut off long tags in stream posts [#4864](https://github.com/diaspora/diaspora/issues/4864) * Do not replace earlier appearances of the name while mentioning somebody [#4868](https://github.com/diaspora/diaspora/issues/4868) +* Catch exceptions when trying to decode an invalid URI [#4874](https://github.com/diaspora/diaspora/issues/4874) ## Features * You can report a single post by clicking the correct icon in the controler section [#4517](https://github.com/diaspora/diaspora/pull/4517) diff --git a/app/assets/javascripts/app/helpers/text_formatter.js b/app/assets/javascripts/app/helpers/text_formatter.js index d5ae68444..9f27029c6 100644 --- a/app/assets/javascripts/app/helpers/text_formatter.js +++ b/app/assets/javascripts/app/helpers/text_formatter.js @@ -45,9 +45,12 @@ $(function() { } // url*DE*code as much as possible - while( unicodeUrl.indexOf("%") !== -1 && unicodeUrl != decodeURI(unicodeUrl) ) { - unicodeUrl = decodeURI(unicodeUrl); + try { + while( unicodeUrl.indexOf("%") !== -1 && unicodeUrl != decodeURI(unicodeUrl) ) { + unicodeUrl = decodeURI(unicodeUrl); + } } + catch(e){} // markdown doesn't like '(' or ')' anywhere, except where it wants var workingUrl = unicodeUrl.replace(/\(/, "%28").replace(/\)/, "%29"); diff --git a/spec/javascripts/app/helpers/text_formatter_spec.js b/spec/javascripts/app/helpers/text_formatter_spec.js index 334321d5a..14d8a149c 100644 --- a/spec/javascripts/app/helpers/text_formatter_spec.js +++ b/spec/javascripts/app/helpers/text_formatter_spec.js @@ -88,7 +88,8 @@ describe("app.helpers.textFormatter", function(){ "http://موقع.وزارة-الاتصالات.مصر/", // example from #3082 "http:///scholar.google.com/citations?view_op=top_venues", "http://lyricstranslate.com/en/someone-you-നിന്നെ-പോലൊരാള്‍.html", // example from #3063, - "http://de.wikipedia.org/wiki/Liste_der_Abkürzungen_(Netzjargon)" // #3645 + "http://de.wikipedia.org/wiki/Liste_der_Abkürzungen_(Netzjargon)", // #3645 + "http://wiki.com/?query=Kr%E4fte", // #4874 ]; this.asciiUrls = [ "http://www.xn--brgerentscheid-krankenhuser-xkc78d.de", @@ -96,7 +97,8 @@ describe("app.helpers.textFormatter", function(){ "http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/", "http:///scholar.google.com/citations?view_op=top_venues", "http://lyricstranslate.com/en/someone-you-%E0%B4%A8%E0%B4%BF%E0%B4%A8%E0%B5%8D%E0%B4%A8%E0%B5%86-%E0%B4%AA%E0%B5%8B%E0%B4%B2%E0%B5%8A%E0%B4%B0%E0%B4%BE%E0%B4%B3%E0%B5%8D%E2%80%8D.html", - "http://de.wikipedia.org/wiki/Liste_der_Abk%C3%BCrzungen_%28Netzjargon%29" + "http://de.wikipedia.org/wiki/Liste_der_Abk%C3%BCrzungen_%28Netzjargon%29", + "http://wiki.com/?query=Kr%E4fte", ]; });