178 lines
16 KiB
Go
178 lines
16 KiB
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||
// SPDX-License-Identifier: MIT
|
||
|
||
package charset
|
||
|
||
import (
|
||
"strings"
|
||
"testing"
|
||
|
||
"code.gitea.io/gitea/modules/setting"
|
||
"code.gitea.io/gitea/modules/test"
|
||
"code.gitea.io/gitea/modules/translation"
|
||
|
||
"github.com/stretchr/testify/assert"
|
||
)
|
||
|
||
type escapeControlTest struct {
|
||
name string
|
||
text string
|
||
status EscapeStatus
|
||
result string
|
||
}
|
||
|
||
var escapeControlTests = []escapeControlTest{
|
||
{
|
||
name: "<empty>",
|
||
},
|
||
{
|
||
name: "single line western",
|
||
text: "single line western",
|
||
result: "single line western",
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "multi line western",
|
||
text: "single line western\nmulti line western\n",
|
||
result: "single line western\nmulti line western\n",
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "multi line western non-breaking space",
|
||
text: "single lineย western\nmulti lineย western\n",
|
||
result: `single line<span class="escaped-code-point" data-escaped="[U+00A0]"><span class="char">ย </span></span>western` + "\n" + `multi line<span class="escaped-code-point" data-escaped="[U+00A0]"><span class="char">ย </span></span>western` + "\n",
|
||
status: EscapeStatus{Escaped: true, HasInvisible: true},
|
||
},
|
||
{
|
||
name: "mixed scripts: western + japanese",
|
||
text: "ๆฅๅฑ็งใใใกใ
ใThen some western.",
|
||
result: "ๆฅๅฑ็งใใใกใ
ใThen some western.",
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "japanese",
|
||
text: "ๆฅๅฑ็งใใใกใ
ใ",
|
||
result: "ๆฅๅฑ็งใใใกใ
ใ",
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "hebrew",
|
||
text: "ืขื ืชืงืืคืช ืืืื ืืขืชืืงื ืืื ืืขืืกืืง ืืืชืืืืงื ืชืืืืชื ืืืื: ืืื ืฉืืืฉื ืืืืกืฃ ืฉื ื ืืกืืืืช ืืืืฉืื ืงืจืงืข, ืืืืืืกืื ืืื'. ืคืจืืฆืช ืืืจื ืฉื ืืืืื ืื, ืคืจื ืืชืจืืืืชืืื ืืืืืืืช ืืืืข ืืืชืืื, ืืืืชื ืืืืืื ืืืชืืืืงื ืืฉืืขืฆืื, ืืชืืงืฃ ืขืจืื ืืจืืื ื. ืืืกื ืฉื ืืืง ืืืืืื ืื ืืงืืืื ืื ืืืชืืืืงื ืืื ืืชื - ืืืฉื, ืืืช ืฉืืกืฃ ืกืืืื ืคืืชืืืจืก ืืืืื ื ืื ืืืชืืืืงื ืืื ืืืกืืก ืืื ืืืืจืื. ืืืืื ืื ื ืืฉืืื ืืืืฆืจื ืืืฉื ืืืืืื ืืืชืืืืช, ืืื ืืจืืฉืื ืื ืฉืขืกืงื ืืืชืืืืงื ืืฉื ืขืฆืื, ืืืืืจ ืืชืืื ืืืงืจื ืขืืื ื ืืืืคืฉื ืืื ืจืง ืืขืืจ ืฉืืืืฉื. ืขื ืืืช, ืืฆืื",
|
||
result: `ืขื ืชืงืืคืช <span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ื</span></span><span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ื</span></span><span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ื</span></span><span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ื</span></span> ืืขืชืืงื ืืื ืืขืืกืืง ืืืชืืืืงื ืชืืืืชื ืืืื: ืืื ืฉืืืฉื ืืืืกืฃ ืฉื ื ืืกืืืืช ืืืืฉืื ืงืจืงืข, ืืืืืืกืื ืืื'. ืคืจืืฆืช ืืืจื ืฉื ืืืืื ืื, ืคืจื ืืชืจืืืืชืืื ืืืืืืืช ืืืืข ืืืชืืื, ืืืืชื ืืืืืื ืืืชืืืืงื ืืฉืืขืฆืื, ืืชืืงืฃ ืขืจืื ืืจืืื ื. ืืืกื ืฉื ืืืง ืืืืืื ืื ืืงืืืื ืื ืืืชืืืืงื ืืื ืืชื - ืืืฉื, ืืืช ืฉืืกืฃ ืกืืืื ืคืืชืืืจืก ืืืืื ื ืื ืืืชืืืืงื ืืื ืืืกืืก ืืื ืืืืจืื. ืืืืื ืื ื ืืฉืืื ืืืืฆืจื ืืืฉื ืืืืืื ืืืชืืืืช, ืืื ืืจืืฉืื ืื ืฉืขืกืงื ืืืชืืืืงื ืืฉื ืขืฆืื, ืืืืืจ ืืชืืื ืืืงืจื ืขืืื ื ืืืืคืฉื ืืื ืจืง ืืขืืจ ืฉืืืืฉื. ืขื ืืืช, ืืฆืื`,
|
||
status: EscapeStatus{Escaped: true, HasAmbiguous: true},
|
||
},
|
||
{
|
||
name: "more hebrew",
|
||
text: `ืืชืงืืคื ืืืืืจืช ืืืชืจ, ืืฉืชืืฉื ืืืืื ืื ืืฉืืืช ืกืืืื ืืชืงืืืช ืืืชืจ, ืฉืื ืืืฆืื ืืืกืคืจืื ืืคื 22 ืืืชืืืช ืืืืคืืืช ืืืืื ื. ืืกืืืื ืืืกืคืจืื ืืื 1 ื-9 ื ืงืืขื ืชืฉืข ืืืืชืืืช ืืจืืฉืื ืืช, ืืชืืกืคืช ืืจืฉ ( ' ) ืืฆื ืืืื ืฉื ืืืืช, ืืืขืื; ืชืฉืข ืืืืชืืืช ืืืืืช ืืืฆืื ืืช ืืขืฉืจืืช ื-10 ืขื 90, ืืืืืืช ืืช ืืืืืช. ืืกืืืื ืืกืคืจืืช ืืื 1000 ื-900,000, ืืฉืชืืฉื ืืืืื ืื ืืืืชื ืืืชืืืช, ืื ืืืกืืคื ืืืืชืืืช ืืช ืืืจืฉ ืืืืงื ืืฆื ืฉืืื ืฉื ืืืืชืืืช, ืืืื. ืืืืืืื ืืืขืื, ืื ืจืื ืืฉืชืืฉื ืืืืื ืื ืืฉื ื ืชืืื ืืืงืื ืืื.
|
||
|
||
ืืืชืืืืงืื ืืืืื ืืจืืฉืื ืืืืื ืืขืชืืงื, ืืืฉ ืืืืืจืื ืืชืืืืืช ืืื ืืฉืืช, ืืื ืชืืืก (624 ืืคื ื"ืก - 546 ืืคื ื"ืก ืืงืืจืื).[1] ืื ืืืื ืื ืืฉืืื ืืกืื ืืื ืื ืฉืืื ืืืื ืืจืืฉืื ืฉืืืืื ืืฉืคื ืืชืืื, ืืื ืจืง ืืืื ืืืชื. ืชืืืก ืืืืื ืฉืืฉืจืื ืืงืืืืื ืืืชืืื ืืฆื ืืื ืฉื ืฉืืงื ืืืืืช ืงืืขืื ืืขืื ืืืกืื ืฉืืืื (ืืฉืคื ืชืืืก ืืจืืฉืื), ืฉืืืืืืช ืืืื ืืช ืขื ืงืืืจ ืืืขืื ืืื ืืืืืช ืืฉืจื (ืืฉืคื ืชืืืก ืืฉื ื), ืฉืืงืืืจ ืืืืง ืืช ืืืขืื ืืฉื ื ืืืงืื ืฉืืืื, ืืฉืืืืืืช ืืืกืืก ืืืฉืืืฉ ืฉืืื-ืฉืืงืืื ืฉืืืช ืื ืืื. ืืืืืกืืช ืื ืื ืฉืืืืช ืืืืืืช ืืืืื ืฉื ืืคืืจืืืืืช ืืขืืจืช ืืืืืช ืฆืืื ืืืงืืืขืช ืืืงืืื ืฉื ืกืคืื ื ืื ืจืืืช ืื ืืืืฃ.
|
||
|
||
ืืฉื ืื 582 ืืคื ื"ืก ืขื 496 ืืคื ื"ืก, ืืงืืจืื, ืื ืืชืืืืงืื ืืฉืื ืืืืืื - ืคืืชืืืจืก. ืืืงืืจืืช ืืจืืฉืื ืืื ืขืืื ืืืขืืื, ืืืืืกืืืจืืื ืื ืืชืงืฉืื ืืืคืจืื ืืช ืืขืืืืืช ืืฉืืืช ืืืกืชืืจืื ืืืืืืืช ืฉื ืงืฉืจื ืื. ืืืืข ืฉืกืืืื ืืชืงืืฆื ืืืกืืืื ืืคืืชืืืจืืืช ืืขืื ืืช ืคืกืืื-ืืชืืืืช ืฉืืืืื ื ืฉ"ืืื ืืกืคืจ", ืื ืืืชืจ ืืืืง ืืื ื ืืชื ืืืืืืช, ืืืืืกื ืืืกืคืจืื ืืฉืืขืืืืช ืืืกืืืืช. ืืื ืื ืจืื ืืคืืชืืืจืืื ืืืขื ืืื ืืช ืืช ืืืืคืื ืืืคืืืื ืืื, ืืืืจื ืืช ืืืืืฆืข ืืืจืืชืืื, ืืืืืฆืข ืืืืืืืจื ืืืืืืฆืข ืืืจืืื ื ืืืืืขื ืืืืฉืืื ืืฉืืืื ื ืืกืคืื. ื ืืชื ืืืืจ ืฉืืคืืชืืืจืืื ืืืื ืืช ืืืืชื ืฉื ืืฉืืจืฉ ืืจืืืืขื ืฉื 2, ืฉืืื ืื ืืืืืกืื ืืจืืืืข ืฉืืืจื ืฆืืขืืชืื 1, ืื ืจืฆืืื ืื, ืื ืชืืืืชื ืืืืชื ืืืขืฉื ืจืง ืฉืืงืืขืื "ืืกืจื ืืืื ืืฉืืชืคืช", ืืืืฉื ืืืกืคืจ ืืื ืจืฆืืื ืื ืืืืืจ ืืืชืจ.[2] ืืืืืจ ืจืืฉืื ืืงืืืื ืฉื ืงืืขืื ืืกืจื ืืืื ืืฉืืชืคืช ืืืคืืข ืืืืืืื "ืชืืืืืืืก" ืฉื ืืคืืืื, ืื ืจืขืืื ืื ืืื ืืืืจ ืขืื ืงืืื ืืื, ืืืื ืืืืืฉืืช ืืคื ื"ืก ืืืืคืืกืืก, ืื ืืืกืืืื ืืคืืชืืืจืืืช, ืืืืื ืืคืืชืืืจืก ืขืฆืื.[3]`,
|
||
result: `ืืชืงืืคื ืืืืืจืช ืืืชืจ, ืืฉืชืืฉื ืืืืื ืื ืืฉืืืช ืกืืืื ืืชืงืืืช ืืืชืจ, ืฉืื ืืืฆืื ืืืกืคืจืื ืืคื 22 ืืืชืืืช ืืืืคืืืช ืืืืื ื. ืืกืืืื ืืืกืคืจืื ืืื 1 ื-9 ื ืงืืขื ืชืฉืข ืืืืชืืืช ืืจืืฉืื ืืช, ืืชืืกืคืช ืืจืฉ ( ' ) ืืฆื ืืืื ืฉื ืืืืช, ืืืขืื; ืชืฉืข ืืืืชืืืช ืืืืืช ืืืฆืื ืืช ืืขืฉืจืืช ื-10 ืขื 90, ืืืืืืช ืืช ืืืืืช. ืืกืืืื ืืกืคืจืืช ืืื 1000 ื-900,000, ืืฉืชืืฉื ืืืืื ืื ืืืืชื ืืืชืืืช, ืื ืืืกืืคื ืืืืชืืืช ืืช ืืืจืฉ ืืืืงื ืืฆื ืฉืืื ืฉื ืืืืชืืืช, ืืืื. ืืืืืืื ืืืขืื, ืื ืจืื ืืฉืชืืฉื ืืืืื ืื ืืฉื ื ืชืืื ืืืงืื ืืื.
|
||
|
||
ืืืชืืืืงืื ืืืืื ืืจืืฉืื ืืืืื ืืขืชืืงื, ืืืฉ ืืืืืจืื ืืชืืืืืช ืืื ืืฉืืช, ืืื ืชืืืก (624 ืืคื ื"<span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ืก</span></span> - 546 ืืคื ื"<span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ืก</span></span> ืืงืืจืื).[1] ืื ืืืื ืื ืืฉืืื ืืกืื ืืื ืื ืฉืืื ืืืื ืืจืืฉืื ืฉืืืืื ืืฉืคื ืืชืืื, ืืื ืจืง ืืืื ืืืชื. ืชืืืก ืืืืื ืฉืืฉืจืื ืืงืืืืื ืืืชืืื ืืฆื ืืื ืฉื ืฉืืงื ืืืืืช ืงืืขืื ืืขืื ืืืกืื ืฉืืืื (ืืฉืคื ืชืืืก ืืจืืฉืื), ืฉืืืืืืช ืืืื ืืช ืขื ืงืืืจ ืืืขืื ืืื ืืืืืช ืืฉืจื (ืืฉืคื ืชืืืก ืืฉื ื), ืฉืืงืืืจ ืืืืง ืืช ืืืขืื ืืฉื ื ืืืงืื ืฉืืืื, ืืฉืืืืืืช ืืืกืืก ืืืฉืืืฉ ืฉืืื-ืฉืืงืืื ืฉืืืช ืื ืืื. ืืืืืกืืช ืื ืื ืฉืืืืช ืืืืืืช ืืืืื ืฉื ืืคืืจืืืืืช ืืขืืจืช ืืืืืช ืฆืืื ืืืงืืืขืช ืืืงืืื ืฉื ืกืคืื ื ืื ืจืืืช ืื ืืืืฃ.
|
||
|
||
ืืฉื ืื 582 ืืคื ื"<span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ืก</span></span> ืขื 496 ืืคื ื"<span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ืก</span></span>, ืืงืืจืื, ืื ืืชืืืืงืื ืืฉืื ืืืืืื - ืคืืชืืืจืก. ืืืงืืจืืช ืืจืืฉืื ืืื ืขืืื ืืืขืืื, ืืืืืกืืืจืืื ืื ืืชืงืฉืื ืืืคืจืื ืืช ืืขืืืืืช ืืฉืืืช ืืืกืชืืจืื ืืืืืืืช ืฉื ืงืฉืจื ืื. ืืืืข ืฉืกืืืื ืืชืงืืฆื ืืืกืืืื ืืคืืชืืืจืืืช ืืขืื ืืช ืคืกืืื-ืืชืืืืช ืฉืืืืื ื ืฉ"ืืื ืืกืคืจ", ืื ืืืชืจ ืืืืง ืืื ื ืืชื ืืืืืืช, ืืืืืกื ืืืกืคืจืื ืืฉืืขืืืืช ืืืกืืืืช. ืืื ืื ืจืื ืืคืืชืืืจืืื ืืืขื ืืื ืืช ืืช ืืืืคืื ืืืคืืืื ืืื, ืืืืจื ืืช ืืืืืฆืข ืืืจืืชืืื, ืืืืืฆืข ืืืืืืืจื ืืืืืืฆืข ืืืจืืื ื ืืืืืขื ืืืืฉืืื ืืฉืืืื ื ืืกืคืื. ื ืืชื ืืืืจ ืฉืืคืืชืืืจืืื ืืืื ืืช ืืืืชื ืฉื ืืฉืืจืฉ ืืจืืืืขื ืฉื 2, ืฉืืื ืื ืืืืืกืื ืืจืืืืข ืฉืืืจื ืฆืืขืืชืื 1, ืื ืจืฆืืื ืื, ืื ืชืืืืชื ืืืืชื ืืืขืฉื ืจืง ืฉืืงืืขืื "ืืกืจื ืืืื ืืฉืืชืคืช", ืืืืฉื ืืืกืคืจ ืืื ืจืฆืืื ืื ืืืืืจ ืืืชืจ.[2] ืืืืืจ ืจืืฉืื ืืงืืืื ืฉื ืงืืขืื ืืกืจื ืืืื ืืฉืืชืคืช ืืืคืืข ืืืืืืื "ืชืืืืืืืก" ืฉื ืืคืืืื, ืื ืจืขืืื ืื ืืื ืืืืจ ืขืื ืงืืื ืืื, ืืืื ืืืืืฉืืช ืืคื ื"<span class="ambiguous-code-point" data-tooltip-content="repo.ambiguous_character"><span class="char">ืก</span></span> ืืืืคืืกืืก, ืื ืืืกืืืื ืืคืืชืืืจืืืช, ืืืืื ืืคืืชืืืจืก ืขืฆืื.[3]`,
|
||
status: EscapeStatus{Escaped: true, HasAmbiguous: true},
|
||
},
|
||
{
|
||
name: "Mixed RTL+LTR",
|
||
text: `Many computer programs fail to display bidirectional text correctly.
|
||
For example, the Hebrew name Sarah (ืฉืจื) is spelled: sin (ืฉ) (which appears rightmost),
|
||
then resh (ืจ), and finally heh (ื) (which should appear leftmost).`,
|
||
result: `Many computer programs fail to display bidirectional text correctly.
|
||
For example, the Hebrew name Sarah (ืฉืจื) is spelled: sin (ืฉ) (which appears rightmost),
|
||
then resh (ืจ), and finally heh (ื) (which should appear leftmost).`,
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "Mixed RTL+LTR+BIDI",
|
||
text: `Many computer programs fail to display bidirectional text correctly.
|
||
For example, the Hebrew name Sarah ` + "\u2067" + `ืฉืจื` + "\u2066\n" +
|
||
`sin (ืฉ) (which appears rightmost), then resh (ืจ), and finally heh (ื) (which should appear leftmost).`,
|
||
result: `Many computer programs fail to display bidirectional text correctly.
|
||
For example, the Hebrew name Sarah ` + "\u2067" + `ืฉืจื` + "\u2066\n" +
|
||
`sin (ืฉ) (which appears rightmost), then resh (ืจ), and finally heh (ื) (which should appear leftmost).`,
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "Accented characters",
|
||
text: string([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}),
|
||
result: string([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}),
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "Program",
|
||
text: "string([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba})",
|
||
result: "string([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba})",
|
||
status: EscapeStatus{},
|
||
},
|
||
{
|
||
name: "CVE testcase",
|
||
text: "if access_level != \"user\u202E \u2066// Check if admin\u2069 \u2066\" {",
|
||
result: `if access_level != "user<span class="escaped-code-point" data-escaped="[U+202E]"><span class="char">` + "\u202e" + `</span></span> <span class="escaped-code-point" data-escaped="[U+2066]"><span class="char">` + "\u2066" + `</span></span>// Check if admin<span class="escaped-code-point" data-escaped="[U+2069]"><span class="char">` + "\u2069" + `</span></span> <span class="escaped-code-point" data-escaped="[U+2066]"><span class="char">` + "\u2066" + `</span></span>" {`,
|
||
status: EscapeStatus{Escaped: true, HasInvisible: true},
|
||
},
|
||
{
|
||
name: "Mixed testcase with fail",
|
||
text: `Many computer programs fail to display bidirectional text correctly.
|
||
For example, the Hebrew name Sarah ` + "\u2067" + `ืฉืจื` + "\u2066\n" +
|
||
`sin (ืฉ) (which appears rightmost), then resh (ืจ), and finally heh (ื) (which should appear leftmost).` +
|
||
"\nif access_level != \"user\u202E \u2066// Check if admin\u2069 \u2066\" {\n",
|
||
result: `Many computer programs fail to display bidirectional text correctly.
|
||
For example, the Hebrew name Sarah ` + "\u2067" + `ืฉืจื` + "\u2066\n" +
|
||
`sin (ืฉ) (which appears rightmost), then resh (ืจ), and finally heh (ื) (which should appear leftmost).` +
|
||
"\n" + `if access_level != "user<span class="escaped-code-point" data-escaped="[U+202E]"><span class="char">` + "\u202e" + `</span></span> <span class="escaped-code-point" data-escaped="[U+2066]"><span class="char">` + "\u2066" + `</span></span>// Check if admin<span class="escaped-code-point" data-escaped="[U+2069]"><span class="char">` + "\u2069" + `</span></span> <span class="escaped-code-point" data-escaped="[U+2066]"><span class="char">` + "\u2066" + `</span></span>" {` + "\n",
|
||
status: EscapeStatus{Escaped: true, HasInvisible: true},
|
||
},
|
||
{
|
||
// UTF-8/16/32 all use the same codepoint for BOM
|
||
// Gitea could read UTF-16/32 content and convert into UTF-8 internally then render it, so we only process UTF-8 internally
|
||
name: "UTF BOM",
|
||
text: "\xef\xbb\xbftest",
|
||
result: "\xef\xbb\xbftest",
|
||
status: EscapeStatus{},
|
||
},
|
||
}
|
||
|
||
func TestEscapeControlReader(t *testing.T) {
|
||
// add some control characters to the tests
|
||
tests := make([]escapeControlTest, 0, len(escapeControlTests)*3)
|
||
copy(tests, escapeControlTests)
|
||
|
||
// if there is a BOM, we should keep the BOM
|
||
addPrefix := func(prefix, s string) string {
|
||
if strings.HasPrefix(s, "\xef\xbb\xbf") {
|
||
return s[:3] + prefix + s[3:]
|
||
}
|
||
return prefix + s
|
||
}
|
||
for _, test := range escapeControlTests {
|
||
test.name += " (+Control)"
|
||
test.text = addPrefix("\u001E", test.text)
|
||
test.result = addPrefix(`<span class="escaped-code-point" data-escaped="[U+001E]"><span class="char">`+"\u001e"+`</span></span>`, test.result)
|
||
test.status.Escaped = true
|
||
test.status.HasInvisible = true
|
||
tests = append(tests, test)
|
||
}
|
||
|
||
for _, tt := range tests {
|
||
t.Run(tt.name, func(t *testing.T) {
|
||
output := &strings.Builder{}
|
||
status, err := EscapeControlReader(strings.NewReader(tt.text), output, &translation.MockLocale{})
|
||
assert.NoError(t, err)
|
||
assert.Equal(t, tt.status, *status)
|
||
assert.Equal(t, tt.result, output.String())
|
||
})
|
||
}
|
||
}
|
||
|
||
func TestSettingAmbiguousUnicodeDetection(t *testing.T) {
|
||
defer test.MockVariableValue(&setting.UI.AmbiguousUnicodeDetection, true)()
|
||
_, out := EscapeControlHTML("aย test", &translation.MockLocale{})
|
||
assert.EqualValues(t, `a<span class="escaped-code-point" data-escaped="[U+00A0]"><span class="char">ย </span></span>test`, out)
|
||
setting.UI.AmbiguousUnicodeDetection = false
|
||
_, out = EscapeControlHTML("aย test", &translation.MockLocale{})
|
||
assert.EqualValues(t, `aย test`, out)
|
||
}
|