Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix: infinite loop in JSDoc parser

Elijah Potter20308b6dc855
diff --git a/demo.md b/demo.md
index cef0b1738..300f52c7f 100644
--- a/demo.md
+++ b/demo.md
@@ -10,5 +10,5 @@ never leaves your device, you don't ned to worry aout us
selling it or using it to train LLMs.
The best part: Harper can give you feedback instantly.
-For most documents, Harper can serve up suggestions in
+For most documents, Harper can serve up suggestions in
under 10 ms.
diff --git a/harper-comments/src/comment_parsers/jsdoc.rs b/harper-comments/src/comment_parsers/jsdoc.rs
index dfbd836c0..e4f72a00c 100644
--- a/harper-comments/src/comment_parsers/jsdoc.rs
+++ b/harper-comments/src/comment_parsers/jsdoc.rs
@@ -67,6 +67,7 @@ fn parse_line(source: &[char]) -> Vec<Token> {
cursor += p;
continue;
}
+ cursor += 1;
}
}
@@ -155,6 +156,13 @@ mod tests {
use crate::TreeSitterParser;
+ #[test]
+ fn escapes_loop() {
+ let source = "/** This should _not_cause an infinite loop: {@ */";
+ let parser = TreeSitterParser::new_from_language_id("javascript").unwrap();
+ Document::new(source, Box::new(parser));
+ }
+
#[test]
fn handles_inline_link() {
let source = "/** See {@link MyClass} and [MyClass's foo property]{@link MyClass#foo}. */";
diff --git a/harper-core/src/linting/matcher.rs b/harper-core/src/linting/matcher.rs
index 5ed8b8f19..ae917f98d 100644
--- a/harper-core/src/linting/matcher.rs
+++ b/harper-core/src/linting/matcher.rs
@@ -190,7 +190,6 @@ impl Matcher {
"simply","grammatical" => "simple grammatical",
"you","r" => "your",
"you","re" => "you're",
- "you","re" => "you are",
"that","s" => "that's",
"That","s" => "That's",
"that","s" => "that is",