Fixed issue with file links: filenames that were already encoded were encoded a second time.

This commit is contained in:
Dario Solera 2009-11-03 09:08:54 +00:00
parent b95f6342a1
commit 24646bd331
3 changed files with 7 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.423")] [assembly: AssemblyVersion("3.0.1.424")]
[assembly: AssemblyFileVersion("3.0.1.423")] [assembly: AssemblyFileVersion("3.0.1.424")]

View file

@ -884,7 +884,8 @@ namespace ScrewTurn.Wiki {
/// <param name="startIndex">The index where to start working.</param> /// <param name="startIndex">The index where to start working.</param>
private static void EncodeFilename(StringBuilder buffer, int startIndex) { private static void EncodeFilename(StringBuilder buffer, int startIndex) {
// 1. Find end of the filename (first pipe or closed square bracket) // 1. Find end of the filename (first pipe or closed square bracket)
// 2. Encode the string // 2. Decode the string, so that it does not break if it was already encoded
// 3. Encode the string
string allData = buffer.ToString(); string allData = buffer.ToString();
@ -892,7 +893,8 @@ namespace ScrewTurn.Wiki {
if(endIndex > startIndex) { if(endIndex > startIndex) {
int len = endIndex - startIndex; int len = endIndex - startIndex;
// {, : and } are used in snippets which are useful in links // {, : and } are used in snippets which are useful in links
string value = Tools.UrlEncode(allData.Substring(startIndex, len)).Replace("%7b", "{").Replace("%7B", "{").Replace("%7d", "}").Replace("%7D", "}").Replace("%3a", ":").Replace("%3A", ":"); string input = Tools.UrlDecode(allData.Substring(startIndex, len));
string value = Tools.UrlEncode(input).Replace("%7b", "{").Replace("%7B", "{").Replace("%7d", "}").Replace("%7D", "}").Replace("%3a", ":").Replace("%3A", ":");
buffer.Remove(startIndex, len); buffer.Remove(startIndex, len);
buffer.Insert(startIndex, value); buffer.Insert(startIndex, value);
} }

View file

@ -193,7 +193,7 @@ namespace ScrewTurn.Wiki {
row["Type"] = "F"; row["Type"] = "F";
row["Name"] = GetItemName(s); row["Name"] = GetItemName(s);
row["Size"] = Tools.BytesToString(details.Size); row["Size"] = Tools.BytesToString(details.Size);
row["WikiMarkupLink"] = "{UP}" + Tools.UrlEncode(s); row["WikiMarkupLink"] = "{UP}" + s;
if(canDownload) { if(canDownload) {
row["Link"] = "GetFile.aspx?File=" + Tools.UrlEncode(s).Replace("'", "&#39;") + "&amp;AsStreamAttachment=1&amp;Provider=" + row["Link"] = "GetFile.aspx?File=" + Tools.UrlEncode(s).Replace("'", "&#39;") + "&amp;AsStreamAttachment=1&amp;Provider=" +
provider.GetType().FullName + "&amp;NoHit=1"; provider.GetType().FullName + "&amp;NoHit=1";