Microsoft の AntiXSSLibrary 4.0 の Sanitizer.GetSafeHtmlFragment を使用すると、HTML フラグメントが次のように変更されることに気付きました。
<pre class="brush: csharp">
</pre>
に:
<pre class="x_brush: x_csharp">
</pre>
残念ながら、彼らの API では、この動作を無効にすることはできません。したがって、正規表現 (C#) を使用して、class="" 属性内で発生する "x_anything" などの文字列を修正して "anything" に置き換えたいと考えています。
これを行うための正規表現を手伝ってくれる人はいますか?
ありがとう
更新- これは私にとってはうまくいきました:
private string FixGetSafeHtmlFragment(string html)
{
string input = html;
Match match = Regex.Match(input, "class=\"(x_).+\"", RegexOptions.IgnoreCase);
if (match.Success)
{
string key = match.Groups[1].Value;
return input.Replace(key, "");
}
return html;
}