diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 2e94716..90064a9 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -844 \ No newline at end of file +854 \ No newline at end of file diff --git a/Common/BBCodes/QuoteSkipper.cs b/Common/BBCodes/QuoteSkipper.cs new file mode 100644 index 0000000..c4dde0f --- /dev/null +++ b/Common/BBCodes/QuoteSkipper.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PJonDevelopment.BBCode; + +namespace FLocal.Common.BBCodes { + class QuoteSkipper : BBCode { + + public QuoteSkipper() : base("quoteskipper") { + } + + public override string Format(ITextFormatter formatter) { + if(this.Name.ToLower() == "q" || this.Name.ToLower() == "quote") { + return ""; + } else if(this.Name.ToLower() == "code") { + return "[code]" + this.InnerBBCode + "[/code]"; + } else { + var sb = new StringBuilder(); + sb.Append("["); + sb.Append(this.Name); + if(this.Default != null && this.Default != "") { + sb.Append("='"); + sb.Append(this.Default.Replace("'", "''")); + sb.Append("'"); + } else { + foreach(var attribute in this.Attributes) { + sb.Append(" "); + sb.Append(attribute.Key); + sb.Append("='"); + sb.Append(attribute.Value.Replace("'", "''")); + sb.Append("'"); + } + } + sb.Append("]"); + if(this.RequireClosingTag) { + sb.Append(this.GetInnerHTML(formatter)); + sb.Append("[/"); + sb.Append(this.Name); + sb.Append("]"); + } + return sb.ToString(); + } + } + + } +} diff --git a/Common/Common.csproj b/Common/Common.csproj index 64c176c..94fa863 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -71,6 +71,7 @@ + diff --git a/Common/UBBParser.cs b/Common/UBBParser.cs index 828bebf..e3a82ab 100644 --- a/Common/UBBParser.cs +++ b/Common/UBBParser.cs @@ -13,6 +13,19 @@ namespace FLocal.Common { private class BBParserGateway { + private class SimpleFormatter : ITextFormatter { + + public static readonly SimpleFormatter instance = new SimpleFormatter(); + + private SimpleFormatter() { + } + + public string Format(string source) { + return source; + } + + } + private class TextFormatter : ITextFormatter { public static readonly TextFormatter instance = new TextFormatter(); @@ -92,6 +105,9 @@ namespace FLocal.Common { private BBCodeParser parser; private ITextFormatter formatter; + private BBCodeParser quotesParser; + private ITextFormatter simpleFormatter; + private BBParserGateway() { this.parser = new BBCodeParser(); this.parser.ElementTypes.Add("b", typeof(BBCodes.B), true); @@ -118,6 +134,12 @@ namespace FLocal.Common { this.parser.ElementTypes.Add("wiki", typeof(BBCodes.Wiki), true); this.parser.ElementTypes.Add("ruwiki", typeof(BBCodes.RuWiki), true); this.formatter = TextFormatter.instance; + + this.quotesParser = new BBCodeParser(); + foreach(var elementType in this.parser.ElementTypes) { + this.quotesParser.ElementTypes.Add(elementType.Key, typeof(BBCodes.QuoteSkipper), elementType.Value.RequireClosingTag); + } + this.simpleFormatter = SimpleFormatter.instance; } public string Parse(string input) { @@ -126,6 +148,11 @@ namespace FLocal.Common { return result; } + public string ParseQuote(string input) { + string result = this.quotesParser.Parse(input).Format(this.simpleFormatter); + return result; + } + } public static string UBBToIntermediate(string UBB) { @@ -137,5 +164,9 @@ namespace FLocal.Common { return shaller; } + public static string StripQuotes(string UBB) { + return BBParserGateway.instance.ParseQuote(UBB); + } + } } diff --git a/IISMainHandler/handlers/response/PMReplyHandler.cs b/IISMainHandler/handlers/response/PMReplyHandler.cs index ad85ee1..9e7922a 100644 --- a/IISMainHandler/handlers/response/PMReplyHandler.cs +++ b/IISMainHandler/handlers/response/PMReplyHandler.cs @@ -20,9 +20,10 @@ namespace FLocal.IISHandler.handlers.response { override protected IEnumerable getSpecificNewMessageData(WebContext context) { PMMessage message = PMMessage.LoadById(int.Parse(context.requestParts[1])); - + string quoted = UBBParser.StripQuotes(message.bodyUBB).Trim(); return new XElement[] { - message.exportToXml(context) + message.exportToXml(context), + new XElement("quoted", quoted), }; } } diff --git a/IISMainHandler/handlers/response/PMReplyToPostHandler.cs b/IISMainHandler/handlers/response/PMReplyToPostHandler.cs index f87d5f3..351454c 100644 --- a/IISMainHandler/handlers/response/PMReplyToPostHandler.cs +++ b/IISMainHandler/handlers/response/PMReplyToPostHandler.cs @@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response { if(quoted != null) quoted = quoted.Trim(); if(quoted == null || quoted == "") { if(post.revision.HasValue) { - quoted = post.latestRevision.body.Trim(); + quoted = UBBParser.StripQuotes(post.latestRevision.body).Trim(); } } diff --git a/IISMainHandler/handlers/response/ReplyHandler.cs b/IISMainHandler/handlers/response/ReplyHandler.cs index d004f53..f617f1f 100644 --- a/IISMainHandler/handlers/response/ReplyHandler.cs +++ b/IISMainHandler/handlers/response/ReplyHandler.cs @@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response { if(quoted != null) quoted = quoted.Trim(); if(quoted == null || quoted == "") { if(post.revision.HasValue) { - quoted = post.latestRevision.body.Trim(); + quoted = UBBParser.StripQuotes(post.latestRevision.body).Trim(); } } diff --git a/templates/Full/PMReply.xslt b/templates/Full/PMReply.xslt index 6a0c196..27f7446 100644 --- a/templates/Full/PMReply.xslt +++ b/templates/Full/PMReply.xslt @@ -53,7 +53,7 @@ [q] - + [/q]