File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ impl TomlError {
2626 let raw = String :: from_utf8 ( raw. to_owned ( ) ) . expect ( "original document was utf8" ) ;
2727
2828 let offset = error. offset ( ) ;
29+ let offset = ( 0 ..=offset)
30+ . rev ( )
31+ . find ( |index| raw. is_char_boundary ( * index) )
32+ . unwrap_or ( 0 ) ;
33+
2934 let mut indices = raw[ offset..] . char_indices ( ) ;
3035 indices. next ( ) ;
3136 let len = if let Some ( ( index, _) ) = indices. next ( ) {
Original file line number Diff line number Diff line change @@ -227,3 +227,12 @@ fn text_error_span() {
227227 let actual = & input[ err. span ( ) . unwrap ( ) ] ;
228228 assert_eq ! ( actual, "" ) ;
229229}
230+
231+ #[ test]
232+ fn fuzzed_68144_error_span ( ) {
233+ let input = "\" \\ ᾂr\" " ;
234+ let err = input. parse :: < toml_edit:: DocumentMut > ( ) . unwrap_err ( ) ;
235+ dbg ! ( err. span( ) ) ;
236+ let actual = & input[ err. span ( ) . unwrap ( ) ] ;
237+ assert_eq ! ( actual, "ᾂ" ) ;
238+ }
You can’t perform that action at this time.
0 commit comments