Skip to content

Commit 87b5930

Browse files
committed
Handle \r\n line endings in encoding detection
Include \r in whitespace for raw byte processing, fixing encoding cookie detection on Windows where files have \r\n line endings.
1 parent f55aa5a commit 87b5930

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/vm/src/stdlib/builtins.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ mod builtins {
121121
let hash_pos = line.iter().position(|&b| b == b'#')?;
122122
if !line[..hash_pos]
123123
.iter()
124-
.all(|&b| b == b' ' || b == b'\t' || b == b'\x0c')
124+
.all(|&b| b == b' ' || b == b'\t' || b == b'\x0c' || b == b'\r')
125125
{
126126
return None;
127127
}
@@ -168,7 +168,7 @@ mod builtins {
168168
// Only check second line if first line is blank or a comment
169169
let trimmed = first
170170
.iter()
171-
.skip_while(|&&b| b == b' ' || b == b'\t' || b == b'\x0c')
171+
.skip_while(|&&b| b == b' ' || b == b'\t' || b == b'\x0c' || b == b'\r')
172172
.copied()
173173
.collect::<Vec<_>>();
174174
if !trimmed.is_empty() && trimmed[0] != b'#' {

0 commit comments

Comments
 (0)