github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.3k stars 4.26k forks source link

Unexpected error highlighting with YARA grammar on linguist #4300

Closed wesinator closed 6 years ago

wesinator commented 6 years ago

Preliminary Steps

Please confirm you have...

Problem Description

YARA language highlighting on Github unexpectedly highlights certain sequences (\x) in red as if it interprets as an error. Not reproducible with the same grammar version in atom: yara_atom_highlight

URL of the affected repository: https://github.com/viper-framework/yara-rules/blob/6a8a376542320c0c58ba15cd027653c76e05af4e/leverage.yar#L15

"\x00"

Expected: \x is not red

lildude commented 6 years ago

This is going to be due to the grammar using a quantifier regexp that is not valid PCRE (as used by GitHub) and but is a valid Oniguruma Regular Expression (as used by Atom).

The incompatibility is in the use of {,2} (and similar usage elsewhere) in the grammar in the regex at https://github.com/blacktop/language-yara/blob/1093d3d528dce6b3c8362dfedfce978cf9979b1e/grammars/yara.cson#L78, specifically {,2} isn't valid PCRE (see quantifiers at https://perldoc.perl.org/perlreref.html#QUANTIFIERS) and needs to be {0,2}. Oniguruma however allows this usage hence it works in Atom.

So as with almost all highlighting issues, this is a problem with the grammar. Please log an issue with the grammar.

Closing as this is not a problem with Linguist.

pchaigno commented 6 years ago

I've sent a pull request (cf. blacktop/language-yara#4) to fix it.