Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff lexer - add extra check for catching duplicate lines #1532

Merged
merged 1 commit into from Jun 3, 2020

Conversation

ci
Copy link
Contributor

@ci ci commented Jun 2, 2020

As described in #1531, the Diff lexer was catching lines that started with either --- or +++ however that includes two consecutive --- lines, or two +++ lines.

This extra checks considers just the two combos, either ---/+++ or +++/---.

Hoping I'm not missing anything and we can't actually have diff types that have two consecutive --- or +++ lines.

This fixes #1531.

As described in rouge-ruby#1531, the Diff lexer was catching
lines that started with either --- or +++ however
that includes two consecutive --- lines, or two
+++ lines.

This extra checks considers just the two combos,
either ---/+++ or +++/---.
@pyrmont pyrmont self-assigned this Jun 2, 2020
@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jun 2, 2020
@pyrmont pyrmont merged commit 226a15a into rouge-ruby:master Jun 3, 2020
@pyrmont
Copy link
Contributor

pyrmont commented Jun 3, 2020

@ci Thanks for taking the time to file the issue and submit the PR. I've merged this in. It'll be part of the next version of Rouge, v3.20.0. That's scheduled for release on Tuesday 9 June 🎉

@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Jun 3, 2020
mattt pushed a commit to NSHipster/rouge that referenced this pull request May 19, 2021
The `detect?` method in the Diff lexer currently returns true if the
text contains a pair of `---` or a pair of `+++`. This causes erroneous
matches with various types of text (e.g. certificates). This commit
updates the method to only match alternating pairs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diff lexer detection catches certificates and other filetypes
2 participants