@@ -8,10 +8,10 @@ namespace ToSic.Razor.Wip
88 /// https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
99 /// https://cheatsheetseries.owasp.org/cheatsheets/DotNet_Security_Cheat_Sheet.html#a7-cross-site-scripting-xss
1010 /// </summary>
11- internal class XssPrevention
11+ public class XssPrevention
1212 {
1313 /// <summary>
14- /// Output Encoding for "JSON-LD Context "
14+ /// Output Encoding for "JSON-LD Contexts "
1515 /// https://w3c.github.io/json-ld-syntax/#restrictions-for-contents-of-json-ld-script-elements
1616 /// https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#output-encoding-for-javascript-contexts
1717 /// Authors should avoid using character sequences in scripts embedded in HTML which may be confused with a
@@ -20,14 +20,11 @@ internal class XssPrevention
2020 /// </summary>
2121 /// <param name="unsafeJsonLd"></param>
2222 /// <returns></returns>
23- internal static string JsonLdScriptEncoding ( string unsafeJsonLd ) => unsafeJsonLd
24- . Replace ( "<!--" , @"\u003C!--" , StringComparison . OrdinalIgnoreCase )
25- . Replace ( "<script" , @"\u003Cscript" , StringComparison . OrdinalIgnoreCase )
26- . Replace ( "-->" , @"--\u003E" , StringComparison . OrdinalIgnoreCase )
27- // TODO @STV: use </script and NOT </script> - the closing tag can be much later
28- // also write a test to verify
29- // and also a test to verify different script cases
30- . Replace ( "</script>" , @"\u003C/script>" , StringComparison . OrdinalIgnoreCase ) ;
23+ public static string JsonLdScriptEncoding ( string unsafeJsonLd ) => unsafeJsonLd
24+ . Replace ( "<!--" , "<" , @"\u003C" , StringComparison . OrdinalIgnoreCase )
25+ . Replace ( "<script" , "<" , @"\u003C" , StringComparison . OrdinalIgnoreCase )
26+ . Replace ( "-->" , ">" , @"\u003E" , StringComparison . OrdinalIgnoreCase )
27+ . Replace ( "</script" , "<" , @"\u003C" , StringComparison . OrdinalIgnoreCase ) ;
3128
3229 ///// <summary>
3330 ///// Output Encoding for "HTML Contexts"
0 commit comments