Skip to content

Commit 2d7b1fa

Browse files
Fix crash when parsing multiline CRLF comment (#302)
1 parent 860b1f0 commit 2d7b1fa

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

fluent-syntax/src/parser/comment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ where
3131

3232
if self.ptr == self.length {
3333
break;
34-
} else if self.is_current_byte(b'\n') {
34+
} else if self.is_eol() {
3535
content.push(self.get_comment_line());
3636
} else {
3737
if let Err(e) = self.expect_byte(b' ') {
@@ -52,7 +52,7 @@ where
5252

5353
pub(super) fn skip_comment(&mut self) {
5454
loop {
55-
while self.ptr < self.length && !self.is_current_byte(b'\n') {
55+
while self.ptr < self.length && !self.is_eol() {
5656
self.ptr += 1;
5757
}
5858
self.ptr += 1;

fluent-syntax/tests/fixtures/crlf.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
# Term Comment
3+
# with a blank last line.
4+
#
25
key01 = Value 01
36
key02 =
47

fluent-syntax/tests/fixtures/crlf.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
]
1818
},
1919
"attributes": [],
20-
"comment": null
20+
"comment": {
21+
"type": "Comment",
22+
"content": "Term Comment\nwith a blank last line.\n"
23+
}
2124
},
2225
{
2326
"type": "Message",

0 commit comments

Comments
 (0)