mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-04 07:33:44 +09:00
fix(markup): don't escape ambiguous characters in MathML (#39493)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -141,6 +141,12 @@ then resh (ר), and finally heh (ה) (which should appear leftmost).`,
|
||||
result: `O<span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character:𝐾 [U+1D43E],K [U+004B]"><span class="char">𝐾</span></span>`,
|
||||
status: EscapeStatus{Escaped: true, HasAmbiguous: true},
|
||||
},
|
||||
{
|
||||
name: "ambiguous in math",
|
||||
text: "<math><mo>−</mo><mi>b</mi></math> −",
|
||||
result: `<math><mo>−</mo><mi>b</mi></math> <span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character:− [U+2212],- [U+002D]"><span class="char">−</span></span>`,
|
||||
status: EscapeStatus{Escaped: true, HasAmbiguous: true},
|
||||
},
|
||||
}
|
||||
|
||||
func TestEscapeControlReader(t *testing.T) {
|
||||
@@ -156,6 +162,24 @@ func TestEscapeControlReader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrackHtmlTag(t *testing.T) {
|
||||
e := &escapeStreamer{}
|
||||
for _, tt := range []struct {
|
||||
parts []string
|
||||
inMath bool
|
||||
}{
|
||||
{[]string{"<ma", `TH display="block">`}, true},
|
||||
{[]string{"<mo>"}, true},
|
||||
{[]string{"</MA", "th>"}, false},
|
||||
{[]string{"<mathx>"}, false},
|
||||
} {
|
||||
for _, part := range tt.parts {
|
||||
e.trackHtmlTag([]byte(part))
|
||||
}
|
||||
assert.Equal(t, tt.inMath, e.inTagMath, "%v", tt.parts)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSettingAmbiguousUnicodeDetection(t *testing.T) {
|
||||
defer test.MockVariableValue(&setting.UI.AmbiguousUnicodeDetection, true)()
|
||||
_, out := EscapeControlHTML("a test", &translation.MockLocale{})
|
||||
|
||||
Reference in New Issue
Block a user