Fixed #523: transclusion anti-loop is disabled for non-page-content formatting.

This commit is contained in:
Dario Solera 2010-05-01 10:16:10 +00:00
parent 1810a46c46
commit e2e0d334eb
2 changed files with 15 additions and 8 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.2.534")] [assembly: AssemblyVersion("3.0.2.535")]
[assembly: AssemblyFileVersion("3.0.2.534")] [assembly: AssemblyFileVersion("3.0.2.535")]

View file

@ -2470,20 +2470,27 @@ namespace ScrewTurn.Wiki {
pageName = NameTools.GetFullName(currentNamespace, pageName); pageName = NameTools.GetFullName(currentNamespace, pageName);
} }
} }
PageInfo info = Pages.FindPage(pageName); PageInfo transcludedPage = Pages.FindPage(pageName);
if(info != null && (current != null && info.FullName != current.FullName)) { // Avoid circular transclusion! // Avoid circular transclusion
bool transclusionAllowed =
transcludedPage != null &&
(current != null &&
transcludedPage.FullName != current.FullName ||
context != FormattingContext.PageContent && context != FormattingContext.TranscludedPageContent);
if(transclusionAllowed) {
string currentUsername = SessionFacade.GetCurrentUsername(); string currentUsername = SessionFacade.GetCurrentUsername();
string[] currentGroups = SessionFacade.GetCurrentGroupNames(); string[] currentGroups = SessionFacade.GetCurrentGroupNames();
bool canView = AuthChecker.CheckActionForPage(info, Actions.ForPages.ReadPage, currentUsername, currentGroups); bool canView = AuthChecker.CheckActionForPage(transcludedPage, Actions.ForPages.ReadPage, currentUsername, currentGroups);
if(canView) { if(canView) {
dummy = new StringBuilder(); dummy = new StringBuilder();
dummy.Append(@"<div class=""transcludedpage"">"); dummy.Append(@"<div class=""transcludedpage"">");
dummy.Append(FormattingPipeline.FormatWithPhase3( dummy.Append(FormattingPipeline.FormatWithPhase3(
FormattingPipeline.FormatWithPhase1And2(Content.GetPageContent(info, true).Content, FormattingPipeline.FormatWithPhase1And2(Content.GetPageContent(transcludedPage, true).Content,
false, FormattingContext.TranscludedPageContent, info), false, FormattingContext.TranscludedPageContent, transcludedPage),
FormattingContext.TranscludedPageContent, info)); FormattingContext.TranscludedPageContent, transcludedPage));
dummy.Append("</div>"); dummy.Append("</div>");
sb.Insert(match.Index, dummy.ToString()); sb.Insert(match.Index, dummy.ToString());
} }