Stage 7b: vectors of the ends of a line and of the separator

Two injected faults went unseen: utf8.DecodeLastRune accepting a rune
that does not end at the end of the line, and the position of the
separator checked one byte short for a string that is not ASCII. The
generator now writes lines whose ends are a space next to a stray
continuation byte or a space cut short, which TrimSpace keeps, and
strings with a byte that is not ASCII and a separator 6, 7 or 8 bytes
before the end. Go and Dart agree on all of them, and the tests now see
both faults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v0.11
dev 1 day ago
parent ecc11be74d
commit 2f35979e45

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -492,6 +492,15 @@ func variants(s, hrp string, data []byte, full bool) []string {
out = append(out, casing(encode5(strings.ToLower(hrp[:n-2]), append(bytes.Clone(v), 0, 0))))
out = append(out, casing(encode5(strings.ToLower(hrp[:n-1]+"1"), v[:len(v)-1])))
out = append(out, casing(encode5("", append(bytes.Clone(v), bytes.Repeat([]byte{0}, n+1)...))))
// A byte that is not ASCII and a separator 6, 7 or 8 bytes before the
// end: the position of the separator is checked first.
for _, bad := range []string{"\xff", "é"} {
for _, back := range []int{6, 7, 8} {
b := []byte(s[:3] + bad + s[3+len(bad):])
b[len(b)-back] = '1'
out = append(out, string(b))
}
}
// Bytes that are not ASCII or not UTF-8, in place of as many bytes.
for _, bad := range []string{"\xff", "\x80", "\xc0\x80", "\xe0\x80\x80", "\xed\xa0\x80", "\xf4\x90\x80\x80", "\xc3", "é", "€", "İ", "ß", "Dž", " ", "<22>", "\U0001f600"} {
for _, at := range []int{0, 3, n, n + 1, len(s) - len(bad)} {
@ -759,6 +768,14 @@ func readSection() []obj {
plain("a byte that is not UTF-8 before the key", "\xff"+s1)
plain("NEL alone, not UTF-8", "\x85"+s1)
plain("NEL in UTF-8", "\u0085"+s1+"\u0085")
// The ends of a line that are not quite a space: utf8.DecodeLastRune
// and DecodeRune give U+FFFD for them, which TrimSpace keeps.
plain("a space and a stray continuation byte at the end", s1+ideographicSpace+"\x80")
plain("a stray continuation byte and a space at the start", "\x80"+ideographicSpace+s1)
plain("a space cut at the end", s1+ideographicSpace[:2])
plain("a space cut at the start", ideographicSpace[1:]+s1)
plain("four continuation bytes after a space", s1+ideographicSpace+"\x80\x80\x80\x80")
plain("a space after the key and a stray byte", s1+" \x80")
plain("a key cut", s1[:78])
plain("a key and a byte", s1+"x")
plain("age-encryption.org/v1 without LF", "age-encryption.org/v1")

Loading…
Cancel
Save

Powered by TurnKey Linux.