Skip to content

Commit b35656c

Browse files
committed
fix hostname tokenizing of newline, carriage return and tab
1 parent e2c6c2c commit b35656c

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/testdata/urlpatterntestdata.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,15 +2494,33 @@
24942494
},
24952495
{
24962496
"pattern": [{ "hostname": "bad\nhostname" }],
2497-
"expected_obj": "error"
2497+
"inputs": [{ "hostname": "badhostname" }],
2498+
"expected_obj": {
2499+
"hostname": "badhostname"
2500+
},
2501+
"expected_match": {
2502+
"hostname": { "input": "badhostname", "groups": {} }
2503+
}
24982504
},
24992505
{
25002506
"pattern": [{ "hostname": "bad\rhostname" }],
2501-
"expected_obj": "error"
2507+
"inputs": [{ "hostname": "badhostname" }],
2508+
"expected_obj": {
2509+
"hostname": "badhostname"
2510+
},
2511+
"expected_match": {
2512+
"hostname": { "input": "badhostname", "groups": {} }
2513+
}
25022514
},
25032515
{
25042516
"pattern": [{ "hostname": "bad\thostname" }],
2505-
"expected_obj": "error"
2517+
"inputs": [{ "hostname": "badhostname" }],
2518+
"expected_obj": {
2519+
"hostname": "badhostname"
2520+
},
2521+
"expected_match": {
2522+
"hostname": { "input": "badhostname", "groups": {} }
2523+
}
25062524
},
25072525
{
25082526
"pattern": [{}],

src/tokenizer.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ pub fn tokenize(
160160
);
161161
continue;
162162
}
163+
if tokenizer.code_point == Some('\n') ||
164+
tokenizer.code_point == Some('\r') ||
165+
tokenizer.code_point == Some('\t') {
166+
// ignore newline, carriage return and tab
167+
tokenizer.index = tokenizer.next_index;
168+
continue;
169+
}
163170
if tokenizer.code_point == Some('{') {
164171
tokenizer.add_token_with_default_pos_and_len(TokenType::Open);
165172
continue;

0 commit comments

Comments
 (0)