From 989819844f561ac3a8254356cae471ee024ce826 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Jun 2017 16:14:39 +0900 Subject: [PATCH] [Modify] Add some checks for the document root path --- websocket-sharp/Server/HttpServer.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 65122956..f2f66742 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -537,7 +537,15 @@ namespace WebSocketSharp.Server /// The value specified for a set operation is . /// /// - /// The value specified for a set operation is an empty string. + /// + /// The value specified for a set operation is an empty string. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation is an absolute root. + /// /// public string RootPath { get { @@ -551,6 +559,16 @@ namespace WebSocketSharp.Server if (value.Length == 0) throw new ArgumentException ("An empty string.", "value"); + value = value.TrimSlashOrBackslashFromEnd (); + if (value == "/") + throw new ArgumentException ("An absolute root.", "value"); + + if (value == "\\") + throw new ArgumentException ("An absolute root.", "value"); + + if (value.Length == 2 && value[1] == ':') + throw new ArgumentException ("An absolute root.", "value"); + string msg; if (!canSet (out msg)) { _log.Warn (msg); @@ -563,7 +581,7 @@ namespace WebSocketSharp.Server return; } - _rootPath = value.TrimSlashOrBackslashFromEnd (); + _rootPath = value; } } }