Skip to content

Commit e0b8b94

Browse files
committed
Fix invalid utf8 slicing in EscapeQuotedString
This could previously panick with multi-byte utf8 characters: datafusion-sqlparser-rs-896df239ce2264c8/847ddf3/src/ast/value.rs:583:53: end byte index 271 is not a char boundary; it is inside '�' (bytes 270..273 of string)
1 parent 735469a commit e0b8b94

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/ast/value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ impl fmt::Display for EscapeQuotedString<'_> {
577577
// The quote is not escaped.
578578
// Including idx in the range, so the quote at idx will be printed twice:
579579
// in this call to write_str() and in the next one.
580-
f.write_str(&self.string[start_idx..=idx])?;
580+
let end_idx = idx + ch.len_utf8();
581+
f.write_str(&self.string[start_idx..end_idx])?;
581582
start_idx = idx;
582583
}
583584
}

0 commit comments

Comments
 (0)