diff --git a/AssemblyVersion.cs b/AssemblyVersion.cs index bc75f40..923d95c 100644 --- a/AssemblyVersion.cs +++ b/AssemblyVersion.cs @@ -16,5 +16,5 @@ using System.Reflection; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.1.410")] -[assembly: AssemblyFileVersion("3.0.1.410")] +[assembly: AssemblyVersion("3.0.1.411")] +[assembly: AssemblyFileVersion("3.0.1.411")] diff --git a/Core/Formatter.cs b/Core/Formatter.cs index 9b487f2..ec0abf6 100644 --- a/Core/Formatter.cs +++ b/Core/Formatter.cs @@ -232,6 +232,7 @@ namespace ScrewTurn.Wiki { match = ExtendedUpRegex.Match(sb.ToString()); while(match.Success) { if(!IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end)) { + EncodeFilename(sb, match.Index + match.Length); sb.Remove(match.Index, match.Length); string prov = match.Groups[1].Value.StartsWith(":") ? match.Value.Substring(4, match.Value.Length - 5) : match.Value.Substring(3, match.Value.Length - 4); string page = null; @@ -869,6 +870,26 @@ namespace ScrewTurn.Wiki { return sb.ToString(); } + /// + /// Encodes a filename used in combination with {UP} tags. + /// + /// The buffer. + /// The index where to start working. + private static void EncodeFilename(StringBuilder buffer, int startIndex) { + // 1. Find end of the filename (first pipe or closed square bracket) + // 2. Encode the string + + string allData = buffer.ToString(); + + int endIndex = allData.IndexOfAny(new[] { '|', ']' }, startIndex); + if(endIndex > startIndex) { + int len = endIndex - startIndex; + string value = Tools.UrlEncode(allData.Substring(startIndex, len)); + buffer.Remove(startIndex, len); + buffer.Insert(startIndex, value); + } + } + /// /// Builds the anchor markup for a header. ///