Fixed and closed #460: illegal characters in request are no longer a problem.

This commit is contained in:
Dario Solera 2010-01-14 08:02:35 +00:00
parent eb7d19e8f6
commit 704c1199ae
2 changed files with 15 additions and 3 deletions

View file

@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Text;
@ -16,8 +17,19 @@ namespace ScrewTurn.Wiki {
/// Properly routes the current virtual request to a physical ASP.NET page.
/// </summary>
public static void RouteCurrentRequest() {
string physicalPath = null;
try {
physicalPath = HttpContext.Current.Request.PhysicalPath;
}
catch(ArgumentException) {
// Illegal characters in path
HttpContext.Current.Response.Redirect("~/PageNotFound.aspx");
return;
}
// Extract the physical page name, e.g. MainPage, Edit or Category
string pageName = Path.GetFileNameWithoutExtension(HttpContext.Current.Request.PhysicalPath);
string pageName = Path.GetFileNameWithoutExtension(physicalPath);
// Exctract the extension, e.g. .ashx or .aspx
string ext = Path.GetExtension(HttpContext.Current.Request.PhysicalPath).ToLowerInvariant();
// Remove trailing dot, .ashx -> ashx