From f8685cfc394f665c8bf7e0f8dc44d6a6fbdb2ca5 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 1 Dec 2023 21:26:53 -0500 Subject: [PATCH] enh(perl) fix false-positive variable match at end of string --- CHANGES.md | 2 ++ src/languages/perl.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 89b141b1d1..911e6a1387 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ Core Grammars: +- enh(perl) fix false-positive variable match at end of string - fix(cpp) not all kinds of number literals are highlighted correctly [Lê Duy Quang][] - fix(css) fix overly greedy pseudo class matching [Bradley Mackey][] - enh(arcade) updated to ArcGIS Arcade version 1.24 [Kristian Ekenes][] @@ -22,6 +23,7 @@ Developer Tool: - enh(tools): order CSS options picklist [David Schach][] - enh(tools): remove duplicate CSS options [David Schach][] +[Josh Goebel]: https://github.com/joshgoebel [Lê Duy Quang]: https://github.com/leduyquang753 [Mohamed Ali]: https://github.com/MohamedAli00949 [Bradley Mackey]: https://github.com/bradleymackey diff --git a/src/languages/perl.js b/src/languages/perl.js index f8923b8884..677dc48beb 100644 --- a/src/languages/perl.js +++ b/src/languages/perl.js @@ -270,7 +270,7 @@ export default function(hljs) { variants: [ { begin: /\$\d/ }, { begin: regex.concat( - /[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, + /[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, // negative look-ahead tries to avoid matching patterns that are not // Perl at all like $ident$, @ident@, etc. `(?![A-Za-z])(?![@$%])` @@ -278,7 +278,7 @@ export default function(hljs) { }, { // Only $= is a special Perl variable and one can't declare @= or %=. - begin: /[$%@][^\s\w{=]|\$=/, + begin: /[$%@](?!")[^\s\w{=]|\$=/, relevance: 0 } ],