From df9cdacc668fa31fc4bc8f820a90afaf10d99aad Mon Sep 17 00:00:00 2001 From: Dario Solera Date: Sat, 1 May 2010 14:49:31 +0000 Subject: [PATCH] Fixed and closed #508: edit section link completely removed from output if current user does not have editing permissions. --- AssemblyVersion.cs | 4 ++-- Core/Formatter.cs | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/AssemblyVersion.cs b/AssemblyVersion.cs index 40e1038..99fb48e 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.2.537")] -[assembly: AssemblyFileVersion("3.0.2.537")] +[assembly: AssemblyVersion("3.0.2.538")] +[assembly: AssemblyFileVersion("3.0.2.538")] diff --git a/Core/Formatter.cs b/Core/Formatter.cs index 3a32a44..23578ce 100644 --- a/Core/Formatter.cs +++ b/Core/Formatter.cs @@ -2424,9 +2424,30 @@ namespace ScrewTurn.Wiki { if(canEdit || canEditWithApproval) { sb.Replace(EditSectionPlaceHolder, Exchanger.ResourceExchanger.GetResource("Edit")); } - else sb.Replace(EditSectionPlaceHolder, ""); } - else sb.Replace(EditSectionPlaceHolder, ""); + + // Remove all placeholders left in the page and their wrapping link + try { + int editSectionPhIdx = 0; + do { + string tempString = sb.ToString(); + editSectionPhIdx = tempString.IndexOf(EditSectionPlaceHolder); + if(editSectionPhIdx >= 0) { + // Find first '<' before index, and first '>' after index + int openingIndex = editSectionPhIdx; + while(openingIndex > 0 && tempString[openingIndex] != '<') { + openingIndex--; + } + int closingIndex = tempString.IndexOf('>', editSectionPhIdx); + + sb.Remove(openingIndex, closingIndex - openingIndex + 1); + } + } while(editSectionPhIdx >= 0); + } + catch { + // Just in case + sb.Replace(EditSectionPlaceHolder, ""); + } match = SignRegex.Match(sb.ToString()); while(match.Success) {