From 6456fb4cea2a55faf51666fe8ec3434e9a92fed3 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Tue, 13 Jul 2010 08:10:04 +0000 Subject: [PATCH] Wrong url exception imlemented --- IISMainHandler/IISMainHandler.csproj | 1 + IISMainHandler/MainHandler.cs | 8 ++++++-- IISMainHandler/exceptions/WrongUrlException.cs | 14 ++++++++++++++ IISMainHandler/handlers/StaticHandler.cs | 15 ++++++++++----- .../handlers/request/MarkThreadAsReadHandler.cs | 2 +- .../handlers/request/MigrateAccountHandler.cs | 2 +- .../handlers/response/LegacyPHPHandler.cs | 9 ++++++--- .../handlers/response/LegacyUploadHandler.cs | 9 +++++---- 8 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 IISMainHandler/exceptions/WrongUrlException.cs diff --git a/IISMainHandler/IISMainHandler.csproj b/IISMainHandler/IISMainHandler.csproj index 25c1ca3..411c8c5 100644 --- a/IISMainHandler/IISMainHandler.csproj +++ b/IISMainHandler/IISMainHandler.csproj @@ -51,6 +51,7 @@ + diff --git a/IISMainHandler/MainHandler.cs b/IISMainHandler/MainHandler.cs index 8a500b9..4d70c4b 100644 --- a/IISMainHandler/MainHandler.cs +++ b/IISMainHandler/MainHandler.cs @@ -28,8 +28,12 @@ namespace FLocal.IISHandler { } WebContext context = new WebContext(httpcontext); - ISpecificHandler handler = HandlersFactory.getHandler(context); - handler.Handle(context); + try { + ISpecificHandler handler = HandlersFactory.getHandler(context); + handler.Handle(context); + } catch(WrongUrlException) { + (new handlers.WrongUrlHandler()).Handle(context); + } } public void ProcessRequest(HttpContext context) { diff --git a/IISMainHandler/exceptions/WrongUrlException.cs b/IISMainHandler/exceptions/WrongUrlException.cs new file mode 100644 index 0000000..dbfad89 --- /dev/null +++ b/IISMainHandler/exceptions/WrongUrlException.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FLocal.Core; + +namespace FLocal.IISHandler { + class WrongUrlException : FLocalException { + + public WrongUrlException() : base("wrong url") { + } + + } +} diff --git a/IISMainHandler/handlers/StaticHandler.cs b/IISMainHandler/handlers/StaticHandler.cs index 7feea22..bc42cb8 100644 --- a/IISMainHandler/handlers/StaticHandler.cs +++ b/IISMainHandler/handlers/StaticHandler.cs @@ -18,32 +18,37 @@ namespace FLocal.IISHandler.handlers { public void Handle(WebContext context) { if(this.requestParts.Length < 2) { - throw new HttpException(403, "listing not allowed"); + //throw new HttpException(403, "listing not allowed"); + throw new WrongUrlException(); } Regex checker = new Regex("^[a-z][0-9a-z\\-_]*(\\.[a-zA-Z]+)?$", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Singleline); string path = ""; for(int i=1; i