Fixed #392: email addresses are automatically obfuscated.

This commit is contained in:
Dario Solera 2009-10-22 13:47:37 +00:00
parent cb567df541
commit 16bcab85ea
3 changed files with 20 additions and 5 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.1.414")] [assembly: AssemblyVersion("3.0.1.415")]
[assembly: AssemblyFileVersion("3.0.1.414")] [assembly: AssemblyFileVersion("3.0.1.415")]

View file

@ -1649,14 +1649,14 @@ namespace ScrewTurn.Wiki {
if(!isImage) sb.Append(@" class=""emaillink"""); if(!isImage) sb.Append(@" class=""emaillink""");
if(blank) sb.Append(@" target=""_blank"""); if(blank) sb.Append(@" target=""_blank""");
sb.Append(@" href=""mailto:"); sb.Append(@" href=""mailto:");
sb.Append(targetUrl.Replace("&", "%26")); // Trick to let ampersands work in email addresses sb.Append(Tools.ObfuscateText(targetUrl.Replace("&", "%26"))); // Trick to let ampersands work in email addresses
sb.Append(@""" title="""); sb.Append(@""" title=""");
if(!isImage && title.Length > 0) sb.Append(nstripped); if(!isImage && title.Length > 0) sb.Append(nstripped);
else if(isImage && imageTitle.Length > 0) sb.Append(imageTitleStripped); else if(isImage && imageTitle.Length > 0) sb.Append(imageTitleStripped);
else sb.Append(targetUrl); else sb.Append(Tools.ObfuscateText(targetUrl));
sb.Append(@""">"); sb.Append(@""">");
if(title.Length > 0) sb.Append(title); if(title.Length > 0) sb.Append(title);
else sb.Append(targetUrl); else sb.Append(Tools.ObfuscateText(targetUrl));
sb.Append("</a>"); sb.Append("</a>");
} }
else if(((targetUrl.IndexOf(".") != -1 && !targetUrl.ToLowerInvariant().EndsWith(".aspx")) || targetUrl.EndsWith("/")) && else if(((targetUrl.IndexOf(".") != -1 && !targetUrl.ToLowerInvariant().EndsWith(".aspx")) || targetUrl.EndsWith("/")) &&

View file

@ -554,6 +554,21 @@ namespace ScrewTurn.Wiki {
return hash; return hash;
} }
/// <summary>
/// Obfuscates text, replacing each character with its HTML escaped sequence, for example a becomes <c>&amp;#97;</c>.
/// </summary>
/// <param name="input">The input text.</param>
/// <returns>The output obfuscated text.</returns>
public static string ObfuscateText(string input) {
StringBuilder buffer = new StringBuilder(input.Length * 4);
foreach(char c in input) {
buffer.Append("&#" + ((int)c).ToString("D2") + ";");
}
return buffer.ToString();
}
} }
/// <summary> /// <summary>