Kjosev / pagedown

Automatically exported from code.google.com/p/pagedown
Other
0 stars 0 forks source link

mailto: no correctly rendered #47

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create some markdown with a link to send an email like 
[mail](email@me.com)
2. call the converter on the string
string = '[mail](mailto:email@me.com)'
converter.makeHtml(string);
3.

What is the expected output? What do you see instead?
The output should be 
<a href="mailto:mail@me.com">mail</a>

instead we have
<a href="{absoluteURL}mailto%3Amail@me.com">mail</a>

What version of the product are you using? On what operating system?

Please provide any additional information below.

This has been fixed by tweaking one of the attackLab functions (below), to 
avoid encoding the ":" when preceeded by "mailto".

function encodeProblemUrlChars(url) {
   if (!url)
     return "";
//if we have an "email:" type of link then do not encode the ":"
   else if (/mailto:/.test(url))
     return url;
   else {
     var len = url.length;
     return url.replace(_problemUrlChars, function (match, offset) {
    if (match == "~D") // escape for dollar
          return "%24";
    if (match == ":") { 
      if (offset == len - 1 || /[0-9\/]/.test(url.charAt(offset + 1)))
        return ":"
    } 
    return "%" + match.charCodeAt(0).toString(16);
     });
  }
}

Original issue reported on code.google.com by dmar...@allscenes.com on 17 Nov 2012 at 1:30

Attachments: