You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a Vue <script> with a carriage return (and no linefeed), followed by non-whitespace, followed by whitespace, we try and return a slice that ends before it starts.
It seems likely the logic around line 43 (which is looking for carriage returns specifically) is at fault.
$ echo -e '<script>\ra </script>' > test.vue
$ RUST_BACKTRACE=1 ./target/debug/tokei ./test.vue
thread '<unnamed>' panicked at 'slice index starts at 2 but ends at 1', src/utils/ext.rs:55:10
stack backtrace:
0: rust_begin_unwind
at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
2: core::slice::index::slice_index_order_fail
at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/slice/index.rs:48:5
3: <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index
at /home/mmacnair/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/index.rs:236:13
4: <core::ops::range::RangeInclusive<usize> as core::slice::index::SliceIndex<[T]>>::index
at /home/mmacnair/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/index.rs:404:9
5: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
at /home/mmacnair/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/index.rs:15:9
6: <[u8] as tokei::utils::ext::SliceExt>::trim_first_and_last_line_of_whitespace
at ./src/utils/ext.rs:55:10
7: tokei::language::syntax::SyntaxCounter::parse_context
at ./src/language/syntax.rs:471:25
8: tokei::language::syntax::SyntaxCounter::perform_multi_line_analysis
at ./src/language/syntax.rs:245:34
9: tokei::language::language_type::LanguageType::parse_lines
at ./src/language/language_type.rs:154:23
10: tokei::language::language_type::LanguageType::parse_from_slice
at ./src/language/language_type.rs:119:13
Found through fuzzing after around 80 million test cases. See #726.
The text was updated successfully, but these errors were encountered:
Given a Vue <script> with a carriage return (and no linefeed), followed by non-whitespace, followed by whitespace, we try and return a slice that ends before it starts.
It seems likely the logic around line 43 (which is looking for carriage returns specifically) is at fault.
Found through fuzzing after around 80 million test cases. See #726.
The text was updated successfully, but these errors were encountered: