Merge pull request #5574 from svbergerem/fix-linkify
Fix markdown-it linkify blocking Firefox
This commit is contained in:
commit
6502000429
3 changed files with 83 additions and 107 deletions
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
url = // rebuild the url
|
||||
(!addr.scheme ? '' : addr.scheme +
|
||||
( (addr.scheme.toLowerCase()=="mailto") ? ':' : '://')) +
|
||||
( (addr.scheme.toLowerCase()=="mailto" || addr.scheme.toLowerCase()=="xmpp") ? ':' : '://')) +
|
||||
(!addr.user ? '' : addr.user +
|
||||
(!addr.pass ? '' : ':'+addr.pass) + '@') +
|
||||
punycode.toASCII(addr.host) +
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -88,7 +88,9 @@ describe("app.helpers.textFormatter", function(){
|
|||
"http://japan.co.jp",
|
||||
"www.mygreat-example-website.de",
|
||||
"www.jenseitsderfenster.de", // from issue #3468
|
||||
"www.google.com"
|
||||
"www.google.com",
|
||||
"xmpp:podmin@pod.tld",
|
||||
"mailto:podmin@pod.tld"
|
||||
];
|
||||
|
||||
var formattedText = this.formatter(links.join(" "));
|
||||
|
|
@ -195,6 +197,12 @@ describe("app.helpers.textFormatter", function(){
|
|||
});
|
||||
|
||||
context("misc breakage and/or other issues with weird urls", function(){
|
||||
it("doesn't crash Firefox", function() {
|
||||
var content = "antifaschistisch-feministische ://"
|
||||
var parsed = this.formatter(content);
|
||||
expect(parsed).toContain(content);
|
||||
});
|
||||
|
||||
it("doesn't crash Chromium - RUN ME WITH CHROMIUM! (issue #3553)", function() {
|
||||
|
||||
var text_part = 'Revert "rails admin is conflicting with client side validations: see https://github.com/sferik/rails_admin/issues/985"';
|
||||
|
|
@ -226,6 +234,34 @@ describe("app.helpers.textFormatter", function(){
|
|||
expect(parsed).toContain(this.correctHref);
|
||||
});
|
||||
});
|
||||
|
||||
it("doesn't fail for misc urls", function() {
|
||||
var contents = [
|
||||
'https://foo.com!',
|
||||
'ftp://example.org:8080'
|
||||
];
|
||||
var results = [
|
||||
'<p><a href="https://foo.com" target="_blank">https://foo.com</a>!</p>',
|
||||
'<p><a href="ftp://example.org:8080" target="_blank">ftp://example.org:8080</a></p>'
|
||||
];
|
||||
for (var i = 0; i < contents.length; i++) {
|
||||
expect(this.formatter(contents[i])).toContain(results[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context("real world examples", function(){
|
||||
it("renders them as expected", function(){
|
||||
var contents = [
|
||||
'oh, cool, nginx 1.7.9 supports json autoindexes: http://nginx.org/en/docs/http/ngx_http_autoindex_module.html#autoindex_format'
|
||||
];
|
||||
var results = [
|
||||
'<p>oh, cool, nginx 1.7.9 supports json autoindexes: <a href="http://nginx.org/en/docs/http/ngx_http_autoindex_module.html#autoindex_format" target="_blank">http://nginx.org/en/docs/http/ngx_http_autoindex_module.html#autoindex_format</a></p>'
|
||||
];
|
||||
for (var i = 0; i < contents.length; i++) {
|
||||
expect(this.formatter(contents[i])).toContain(results[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue