caddyhttp: fix randString sameCase dictionary to match its docs

The doc comment says randString excludes confusing characters like
I, l, 1, 0, O. When sameCase is true, uppercase letters are excluded,
and l and o should also be excluded. But the dictionary used when
sameCase was true still contained '0'. Drop it, and update the test
to match the actual documented exclusions.

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
add-tests
Mohammed Al Sahaf 2026-08-30 18:23:09 +03:00
parent efbb7bc8b8
commit aea7b9bdf0
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View File

@ -96,7 +96,7 @@ func randString(n int, sameCase bool) string {
}
dict := []byte("abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY23456789")
if sameCase {
dict = []byte("abcdefghijkmnpqrstuvwxyz0123456789")
dict = []byte("abcdefghijkmnpqrstuvwxyz123456789")
}
b := make([]byte, n)
for i := range b {

View File

@ -164,7 +164,7 @@ func TestRandString_NoConfusingChars(t *testing.T) {
{
name: "same case excludes l,0",
sameCase: true,
excluded: []rune{'l', 'o'},
excluded: []rune{'l', '0'},
},
}