From 4d37449b96827d471088469aa14d39fc01592176 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Sat, 18 Sep 2010 22:39:48 +0000 Subject: [PATCH] URLs parsing in UBB improved --- Builder/IISMainHandler/build.txt | 2 +- Common/BBCodes/helpers/UrlProcessor.cs | 30 +++++++++----------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 478c1d4..473aa3c 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -1411 \ No newline at end of file +1413 \ No newline at end of file diff --git a/Common/BBCodes/helpers/UrlProcessor.cs b/Common/BBCodes/helpers/UrlProcessor.cs index 22fc013..874d518 100644 --- a/Common/BBCodes/helpers/UrlProcessor.cs +++ b/Common/BBCodes/helpers/UrlProcessor.cs @@ -68,28 +68,18 @@ namespace FLocal.Common.BBCodes { var urlInfo = new Uri(link); url = urlInfo.ToString(); } - if(title == null) { - if(!isExternal) { - var parts = url.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); - var combinedToLower = string.Join("/", parts).ToLower(); - if(combinedToLower.StartsWith("upload/item/")) { - title = Safe(dataobjects.Upload.LoadById(int.Parse(parts[2])).filename); - } else if(combinedToLower.StartsWith("post/")) { - title = Safe(dataobjects.Post.LoadById(int.Parse(parts[1])).title); - } else if(combinedToLower.StartsWith("thread/")) { - title = Safe(dataobjects.Thread.LoadById(int.Parse(parts[1])).title); - } else if(combinedToLower.StartsWith("board/") || combinedToLower.StartsWith("boardasthread/")) { - title = Safe(dataobjects.Board.LoadById(int.Parse(parts[1])).name); - } else if(combinedToLower.StartsWith("poll/")) { - title = Safe(dataobjects.Poll.LoadById(int.Parse(parts[1])).title); - } else { - title = link; - } - } else { - title = link; + if(isExternal) { + if(title == null) { + title = url; + } + } else { + var linkInfo = URL.UrlManager.Parse(url, new System.Collections.Specialized.NameValueCollection(), true); + url = linkInfo.canonicalFull; + if(title == null) { + title = linkInfo.title; } } - string result = "" + title + ""; + string result = "" + Safe(title) + ""; if(isExternal) { result += ""; }