URLs parsing in UBB improved

main
Inga 🏳‍🌈 14 years ago
parent 16b7cf77a7
commit 4d37449b96
  1. 2
      Builder/IISMainHandler/build.txt
  2. 30
      Common/BBCodes/helpers/UrlProcessor.cs

@ -68,28 +68,18 @@ namespace FLocal.Common.BBCodes {
var urlInfo = new Uri(link); var urlInfo = new Uri(link);
url = urlInfo.ToString(); url = urlInfo.ToString();
} }
if(title == null) { if(isExternal) {
if(!isExternal) { if(title == null) {
var parts = url.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); title = url;
var combinedToLower = string.Join("/", parts).ToLower(); }
if(combinedToLower.StartsWith("upload/item/")) { } else {
title = Safe(dataobjects.Upload.LoadById(int.Parse(parts[2])).filename); var linkInfo = URL.UrlManager.Parse(url, new System.Collections.Specialized.NameValueCollection(), true);
} else if(combinedToLower.StartsWith("post/")) { url = linkInfo.canonicalFull;
title = Safe(dataobjects.Post.LoadById(int.Parse(parts[1])).title); if(title == null) {
} else if(combinedToLower.StartsWith("thread/")) { title = linkInfo.title;
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;
} }
} }
string result = "<a href=\"" + url + "\">" + title + "</a>"; string result = "<a href=\"" + url + "\">" + Safe(title) + "</a>";
if(isExternal) { if(isExternal) {
result += "<img src=\"/static/images/external.png\" border=\"0\"/>"; result += "<img src=\"/static/images/external.png\" border=\"0\"/>";
} }

Loading…
Cancel
Save