Skip to content

Commit cef83ff

Browse files
committed
fix: make keyword_token safe by validating UTF-8 input
1 parent 0ef59ff commit cef83ff

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • vendored/sqlite3-parser/src/dialect

vendored/sqlite3-parser/src/dialect/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ include!(concat!(env!("OUT_DIR"), "/keywords.rs"));
6565
pub(crate) const MAX_KEYWORD_LEN: usize = 17;
6666

6767
pub fn keyword_token(word: &[u8]) -> Option<TokenType> {
68+
let s = std::str::from_utf8(word).ok()?;
6869
KEYWORDS
69-
.get(UncasedStr::new(unsafe { str::from_utf8_unchecked(word) }))
70+
.get(UncasedStr::new(s))
7071
.cloned()
7172
}
7273

0 commit comments

Comments
 (0)