From 1ea61947ba870a33764104a5d11bd22293aa0364 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 May 2019 17:08:17 +0900 Subject: [PATCH] [Modify] Set an empty string if null --- websocket-sharp/Net/Cookie.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 1aeb302f..9a2723f8 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -115,7 +115,7 @@ namespace WebSocketSharp.Net /// internal Cookie () { - init (String.Empty, "\"\"", String.Empty, String.Empty); + init (String.Empty, String.Empty, String.Empty, String.Empty); } #endregion @@ -305,9 +305,6 @@ namespace WebSocketSharp.Net if (name == null) throw new ArgumentNullException ("name"); - if (value == null) - throw new ArgumentNullException ("value"); - if (name.Length == 0) throw new ArgumentException ("An empty string.", "name"); @@ -321,6 +318,9 @@ namespace WebSocketSharp.Net throw new ArgumentException (msg, "name"); } + if (value == null) + value = String.Empty; + if (value.Contains (_reservedCharsForValue)) { if (!value.IsEnclosedIn ('"')) { var msg = "A string not enclosed in double quotes."; @@ -328,12 +328,7 @@ namespace WebSocketSharp.Net } } - init ( - name, - value.Length > 0 ? value : "\"\"", - path ?? String.Empty, - domain ?? String.Empty - ); + init (name, value, path ?? String.Empty, domain ?? String.Empty); } #endregion @@ -728,7 +723,7 @@ namespace WebSocketSharp.Net set { if (value == null) - throw new ArgumentNullException ("value"); + value = String.Empty; if (value.Contains (_reservedCharsForValue)) { if (!value.IsEnclosedIn ('"')) { @@ -737,7 +732,7 @@ namespace WebSocketSharp.Net } } - _value = value.Length > 0 ? value : "\"\""; + _value = value; } }