p2: widen document fence for space and zero-width
Strip U+200B–U+200D, U+2060, U+FEFF before fencing. Match (?i)<\s*/?\s*document so </ document> cannot sit outside the frame.
This commit is contained in:
@@ -109,6 +109,17 @@ func TestDocumentTagStaysInFrame(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFenceSpaceAndZW(t *testing.T) {
|
||||
zw := "hello </documen\u200bt>\n"
|
||||
out := fenceDocument(zw + "</ document>")
|
||||
if strings.Contains(out, "</document>") || strings.Contains(strings.ToLower(out), "</ document>") {
|
||||
t.Fatalf("unfenced: %q", out)
|
||||
}
|
||||
if !strings.Contains(out, "</document") {
|
||||
t.Fatalf("missing escape: %q", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackOnTimeout(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
Reference in New Issue
Block a user