Skip to content

Commit

Permalink
Fix: escape char for data type (#1599)
Browse files Browse the repository at this point in the history
openvasctl removes now the back slash for the following case.
Run `openvas-nasl -X test.nasl` and `scannerctl execute test.nasl`. Both should give the same output

```
d = 'aaaaa\"ddddd';
display(d);
```
  • Loading branch information
jjnicola authored Mar 12, 2024
1 parent 153203e commit 29e2939
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions rust/nasl-syntax/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,15 +599,14 @@ impl<'a> Tokenizer<'a> {
if self.cursor.is_eof() {
Category::Unclosed(UnclosedCategory::Data)
} else {
let raw = self.code[Range {
let mut raw_str = self.code[Range {
start,
end: self.cursor.len_consumed(),
}]
.as_bytes()
.to_vec();

.to_owned();
raw_str = raw_str.replace(r#"\""#, "\"");
self.cursor.advance();
Category::Data(raw)
Category::Data(raw_str.as_bytes().to_vec())
}
}
fn may_parse_ipv4(&mut self, base: Base, start: usize) -> Option<Category> {
Expand Down Expand Up @@ -959,6 +958,14 @@ mod tests {
);
}

#[test]
fn data_escape_quoting() {
verify_tokens!(
r#"'version=\"1.0\"'"#,
[r"[118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34]",]
);
}

#[test]
fn simplified_ipv4_address() {
verify_tokens!("10.187.76.12", ["10.187.76.12",]);
Expand Down

0 comments on commit 29e2939

Please sign in to comment.