From 43a8cdee27e1de239973432bc334ddf0c922ae2e Mon Sep 17 00:00:00 2001
From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Fri, 20 Apr 2012 22:18:33 +0400
Subject: [PATCH] BBCodes.UserMentionProcessor implemented
---
FLocal.Common/BBCodes/User.cs | 5 +----
.../BBCodes/helpers/UserMentionProcessor.cs | 21 +++++++++++++++++++
FLocal.Common/FLocal.Common.csproj | 1 +
3 files changed, 23 insertions(+), 4 deletions(-)
create mode 100644 FLocal.Common/BBCodes/helpers/UserMentionProcessor.cs
diff --git a/FLocal.Common/BBCodes/User.cs b/FLocal.Common/BBCodes/User.cs
index 0b2d914..7993deb 100644
--- a/FLocal.Common/BBCodes/User.cs
+++ b/FLocal.Common/BBCodes/User.cs
@@ -12,10 +12,7 @@ namespace FLocal.Common.BBCodes {
}
public override string Format(IPostParsingContext context, ITextFormatter formatter) {
- var user = dataobjects.User.LoadByName(this.DefaultOrValue);
- context.OnUserMention(user);
- var url = new URL.users.user.Info(user.id.ToString(), null);
- return String.Format("{2}", this.Safe(user.userGroup.name), url.canonical, this.Safe(user.name));
+ return UserMentionProcessor.ProcessUserMention(context, this.DefaultOrValue);
}
}
diff --git a/FLocal.Common/BBCodes/helpers/UserMentionProcessor.cs b/FLocal.Common/BBCodes/helpers/UserMentionProcessor.cs
new file mode 100644
index 0000000..4481653
--- /dev/null
+++ b/FLocal.Common/BBCodes/helpers/UserMentionProcessor.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FLocal.Common.BBCodes {
+ class UserMentionProcessor {
+
+ private static string Safe(string str) {
+ return System.Web.HttpUtility.HtmlEncode(str);
+ }
+
+ public static string ProcessUserMention(IPostParsingContext context, string username) {
+ var user = dataobjects.User.LoadByName(username);
+ context.OnUserMention(user);
+ var url = new URL.users.user.Info(user.id.ToString(), null);
+ return String.Format("{2}", Safe(user.userGroup.name), url.canonical, Safe(user.name));
+ }
+
+ }
+}
diff --git a/FLocal.Common/FLocal.Common.csproj b/FLocal.Common/FLocal.Common.csproj
index add5180..bee8ce6 100644
--- a/FLocal.Common/FLocal.Common.csproj
+++ b/FLocal.Common/FLocal.Common.csproj
@@ -68,6 +68,7 @@
+