Skip to content

Commit 79f0355

Browse files
sverrejohfacebook-github-bot
authored andcommitted
Handle CRLF when parsing docblocks (#4865)
Summary: The dockblock parser doesn't support CRLF, so the \r character becomes part of the identifiers. This fix strips the \r suffix from the text until newline. This fixes #4864 Pull Request resolved: #4865 Reviewed By: evanyeung Differential Revision: D67146972 Pulled By: captbaritone fbshipit-source-id: 767d783f90f062ed58b8e369dfce32a118793bf1
1 parent d4aca13 commit 79f0355

File tree

1 file changed

+5
-1
lines changed
  • compiler/crates/docblock-syntax/src

1 file changed

+5
-1
lines changed

compiler/crates/docblock-syntax/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ impl<'a> DocblockParser<'a> {
238238
/// Read until the end of the line.
239239
fn parse_free_text_line(&mut self) -> ParseResult<SpanString> {
240240
let start = self.offset;
241-
let free_text = self.take_while(|c| c != &'\n');
241+
let mut free_text: String = self.take_while(|c| c != &'\n');
242+
// Handle CRLF by stripping `\r` suffix.
243+
if free_text.ends_with('\r') {
244+
free_text.pop();
245+
}
242246
let end = self.offset;
243247
Ok(SpanString::new(Span::new(start, end), free_text))
244248
}

0 commit comments

Comments
 (0)