Skip to content

Commit

Permalink
Added checks for invalid characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Lucas committed Aug 7, 2024
1 parent 6a59973 commit 3a58515
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 54 deletions.
22 changes: 7 additions & 15 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 39 additions & 39 deletions build/out.asm
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ _11:
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
jz __36_24
jz __36_16
mov byte [rbp-1], 0
jmp __36_25
__36_24:
jmp __36_17
__36_16:
mov byte [rbp-1], 1
__36_25:
__36_17:
cmp byte [rbp-1], 0
jz _11_27
jz _11_19
mov rax, [rbp+16]
add rax, 0x0000000000000000
mov qword [rbp-25], rax
Expand All @@ -162,8 +162,8 @@ _11:
mov rdx, qword [rbp-25]
mov rax, qword [rbp-33]
mov qword [rdx+0], rax
jmp _11_26
_11_27:
jmp _11_18
_11_19:
mov rax, [rbp+16]
add rax, 0x0000000000000000
mov qword [rbp-25], rax
Expand All @@ -179,8 +179,8 @@ _11:
sub rsp, 0x0000000000000049
call _16
add rsp, 0x0000000000000049
_11_28:
_11_26:
_11_20:
_11_18:

leave
ret
Expand Down Expand Up @@ -226,14 +226,14 @@ _13:
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
jz __36_0
jz __36_26
mov byte [rbp-1], 0
jmp __36_1
__36_0:
jmp __36_27
__36_26:
mov byte [rbp-1], 1
__36_1:
__36_27:
cmp byte [rbp-1], 0
jz _13_2
jz _13_28
mov rax, [rbp+16]
add rax, 0x0000000000000000
mov qword [rbp-49], rax
Expand Down Expand Up @@ -268,8 +268,8 @@ _13:
mov qword [rbp+24], rax
leave
ret
_13_3:
_13_2:
_13_29:
_13_28:
mov rax, [rbp+16]
add rax, 0x0000000000000000
mov qword [rbp-41], rax
Expand Down Expand Up @@ -365,14 +365,14 @@ _16:
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
jz __36_29
jz __36_21
mov byte [rbp-1], 0
jmp __36_30
__36_29:
jmp __36_22
__36_21:
mov byte [rbp-1], 1
__36_30:
__36_22:
cmp byte [rbp-1], 0
jz _16_32
jz _16_24
mov rax, [rbp+16]
add rax, 0x0000000000000008
mov qword [rbp-25], rax
Expand All @@ -388,8 +388,8 @@ _16:
mov rdx, qword [rbp-25]
mov rax, qword [rbp-33]
mov qword [rdx+0], rax
jmp _16_31
_16_32:
jmp _16_23
_16_24:
mov rax, [rbp+16]
add rax, 0x0000000000000008
mov qword [rbp-25], rax
Expand All @@ -405,8 +405,8 @@ _16:
sub rsp, 0x0000000000000049
call _16
add rsp, 0x0000000000000049
_16_33:
_16_31:
_16_25:
_16_23:

leave
ret
Expand All @@ -419,14 +419,14 @@ _17:
mov qword [rbp-17], 0
mov rax, qword [rbp-9]
cmp rax, qword [rbp-17]
jz __16_20
jz __16_0
mov byte [rbp-1], 0
jmp __16_21
__16_20:
jmp __16_1
__16_0:
mov byte [rbp-1], 1
__16_21:
__16_1:
cmp byte [rbp-1], 0
jz _17_22
jz _17_2
mov rax, [rbp+16]
add rax, 0x0000000000000000
mov qword [rbp-25], rax
Expand All @@ -435,8 +435,8 @@ _17:
mov qword [rbp+32], rax
leave
ret
_17_23:
_17_22:
_17_3:
_17_2:
mov rax, [rbp+16]
add rax, 0x0000000000000008
mov qword [rbp-25], rax
Expand Down Expand Up @@ -479,14 +479,14 @@ _18:
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
jz __36_16
jz __36_30
mov byte [rbp-1], 0
jmp __36_17
__36_16:
jmp __36_31
__36_30:
mov byte [rbp-1], 1
__36_17:
__36_31:
cmp byte [rbp-1], 0
jz _18_18
jz _18_32
mov rax, [rbp+16]
add rax, 0x0000000000000008
mov qword [rbp-49], rax
Expand Down Expand Up @@ -521,8 +521,8 @@ _18:
mov qword [rbp+24], rax
leave
ret
_18_19:
_18_18:
_18_33:
_18_32:
mov rax, [rbp+16]
add rax, 0x0000000000000008
mov qword [rbp-41], rax
Expand Down
Binary file modified build/out.o
Binary file not shown.
Binary file modified build/out.out
Binary file not shown.
19 changes: 19 additions & 0 deletions src/root/parser/use_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ pub fn parse_uses(s: Span) -> ParseResult<Span, Vec<(PathBuf, Location)>> {
));
}

let mut path_rem = path;
while let Ok((rem, c)) = anychar::<_, ErrorTree>(path_rem) {
if c.is_alphanumeric() || c == '_' || c == '/' {
path_rem = rem;
continue;
}
let mut utf8 = [0u8; 4];
c.encode_utf8(&mut utf8);
let mut utf8_str = "[".to_string();
utf8_str += &utf8.map(|b| format!("{b:02X}")).join(", ");
utf8_str.push(']');


return Err(create_custom_error(
format!("Invalid character in path '{}' - UTF-8 bytes: {}. Allowed characters are alphanumerics, '_' and '/'", c, utf8_str),
path_rem,
));
}

let path_buf = PathBuf::from(format!("{}.why", path));
found_paths.push((path_buf, Location::from_span(&path)));

Expand Down

0 comments on commit 3a58515

Please sign in to comment.