1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net: byte fixes

This commit is contained in:
Alexander Medvednikov
2022-04-15 15:55:39 +03:00
parent fb192d949b
commit af73e195da
18 changed files with 54 additions and 65 deletions

View File

@@ -177,7 +177,7 @@ pub fn (c &Cookie) str() string {
return b.str()
}
fn sanitize(valid fn (byte) bool, v string) string {
fn sanitize(valid fn (u8) bool, v string) string {
mut ok := true
for i in 0 .. v.len {
if valid(v[i]) {
@@ -222,11 +222,11 @@ fn sanitize_cookie_path(v string) string {
return sanitize(valid_cookie_path_byte, v)
}
fn valid_cookie_value_u8(b byte) bool {
fn valid_cookie_value_byte(b u8) bool {
return 0x20 <= b && b < 0x7f && b != `"` && b != `;` && b != `\\`
}
fn valid_cookie_path_u8(b byte) bool {
fn valid_cookie_path_byte(b u8) bool {
return 0x20 <= b && b < 0x7f && b != `!`
}
@@ -300,7 +300,7 @@ fn parse_cookie_value(_raw string, allow_double_quote bool) ?string {
raw = raw.substr(1, raw.len - 1)
}
for i in 0 .. raw.len {
if !valid_cookie_value_u8(raw[i]) {
if !valid_cookie_value_byte(raw[i]) {
return error('http.cookie: invalid cookie value')
}
}