1 files changed, 23 insertions, 0 deletions
diff --git a/ReferenceClientProxyImplementation/Patches/Implementations/JSPatches/DisableSelfXssPatch.cs b/ReferenceClientProxyImplementation/Patches/Implementations/JSPatches/DisableSelfXssPatch.cs
new file mode 100644
index 0000000..59746f4
--- /dev/null
+++ b/ReferenceClientProxyImplementation/Patches/Implementations/JSPatches/DisableSelfXssPatch.cs
@@ -0,0 +1,23 @@
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace ReferenceClientProxyImplementation.Patches.Implementations.JSPatches;
+
+public partial class DisableSelfXssPatch : IPatch {
+ public int GetOrder() => 0;
+
+ public string GetName() => "JS: Disable self-xss warnings";
+ public bool Applies(string relativeName, byte[] content) => relativeName.EndsWith(".js");
+
+ public async Task<byte[]> Execute(string _, byte[] content) {
+ var stringContent = Encoding.UTF8.GetString(content);
+
+ stringContent = SelfXssNullCheckRegex().Replace(stringContent, "false");
+
+ return Encoding.UTF8.GetBytes(stringContent);
+ }
+
+ [GeneratedRegex(@"null != [a-zA-Z0-9]+\.[a-zA-Z0-9]+\.Messages\.SELF_XSS_HEADER", RegexOptions.Compiled)]
+ private static partial Regex SelfXssNullCheckRegex();
+
+}
\ No newline at end of file
|