[Modify] Add some checks for the document root path
This commit is contained in:
parent
9ddeb714bc
commit
989819844f
@ -537,7 +537,15 @@ namespace WebSocketSharp.Server
|
|||||||
/// The value specified for a set operation is <see langword="null"/>.
|
/// The value specified for a set operation is <see langword="null"/>.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
|
/// <para>
|
||||||
/// The value specified for a set operation is an empty string.
|
/// The value specified for a set operation is an empty string.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// -or-
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// The value specified for a set operation is an absolute root.
|
||||||
|
/// </para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public string RootPath {
|
public string RootPath {
|
||||||
get {
|
get {
|
||||||
@ -551,6 +559,16 @@ namespace WebSocketSharp.Server
|
|||||||
if (value.Length == 0)
|
if (value.Length == 0)
|
||||||
throw new ArgumentException ("An empty string.", "value");
|
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;
|
string msg;
|
||||||
if (!canSet (out msg)) {
|
if (!canSet (out msg)) {
|
||||||
_log.Warn (msg);
|
_log.Warn (msg);
|
||||||
@ -563,7 +581,7 @@ namespace WebSocketSharp.Server
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_rootPath = value.TrimSlashOrBackslashFromEnd ();
|
_rootPath = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user