@ -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 - 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 ( 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 ) ... ) ) ) )
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.
// 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 _ , 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 ) } {
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 ( "a byte that is not UTF-8 before the key" , "\xff" + s1 )
plain ( "NEL alone, not UTF-8" , "\x85" + s1 )
plain ( "NEL alone, not UTF-8" , "\x85" + s1 )
plain ( "NEL in UTF-8" , "\u0085" + s1 + "\u0085" )
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 cut" , s1 [ : 78 ] )
plain ( "a key and a byte" , s1 + "x" )
plain ( "a key and a byte" , s1 + "x" )
plain ( "age-encryption.org/v1 without LF" , "age-encryption.org/v1" )
plain ( "age-encryption.org/v1 without LF" , "age-encryption.org/v1" )