浏览代码

fixes #1075 - XSS in "Active Devices" Panel of Admin Dashboard

Luke 9 年之前
父节点
当前提交
9c3119808b
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs

+ 12 - 1
MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs

@@ -175,11 +175,22 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
 
                 if (param.Length == 2)
                 {
-                    result.Add(param[0], param[1].Trim(new[] { '"' }));
+					var value = NormalizeValue (param[1].Trim(new[] { '"' }));
+                    result.Add(param[0], value);
                 }
             }
 
             return result;
         }
+
+		private string NormalizeValue(string value)
+		{
+			if (string.IsNullOrWhiteSpace (value)) 
+			{
+				return value;
+			}
+
+			return System.Net.WebUtility.HtmlEncode(value);
+		}
     }
 }