From a39e0ba396ac4cc88fda32103590840785832b18 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 22 Jul 2024 20:43:38 +0200 Subject: [PATCH 1/2] fix: correctly match files named exactly `.htaccess` in `language_htaccess` --- manifest.json | 2 +- plugins/language_htaccess.lua | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index e6d7422a..fd3a4fae 100644 --- a/manifest.json +++ b/manifest.json @@ -1108,7 +1108,7 @@ "tags": [ "language" ], - "version": "0.1" + "version": "0.1.1" }, { "description": "Syntax for [.gitignore](https://git-scm.com/docs/gitignore), [.dockerignore](https://docs.docker.com/engine/reference/builder/#dockerignore-file) and some other `.*ignore` files", diff --git a/plugins/language_htaccess.lua b/plugins/language_htaccess.lua index acfa419e..69b0e689 100644 --- a/plugins/language_htaccess.lua +++ b/plugins/language_htaccess.lua @@ -165,11 +165,11 @@ local xml_syntax = { syntax.add { name = ".htaccess File", - files = { "^%.htaccess$" }, + files = { PATHSEP .. "%.htaccess$" }, comment = "#", patterns = { -- Comments - { pattern = "#.*\n", type = "comment" }, + { pattern = "#.*", type = "comment" }, -- Strings { pattern = { '"', '"', '\\' }, type = "string" }, { pattern = { "'", "'", '\\' }, type = "string" }, @@ -191,14 +191,14 @@ syntax.add { -- Emails { pattern = "%w+@%w+%.%w+", type = "keyword2" }, -- Rewrite option sections - { pattern = "%f[%S]%b[]", type = "number" }, + { pattern = "%f[%S]%b[]", type = "number" }, -- XML tags { pattern = { "" }, type = "literal", syntax = xml_syntax }, -- Variables { pattern = "[%%$]%d+", type = "keyword2" }, { pattern = "[%%$]%{[%w_:%-]+%}", type = "keyword2" }, -- Numbers - { pattern = "A?%d+", type = "number" }, + { pattern = "A?%d+", type = "number" }, -- Operators { pattern = "%f[%S][!=+%-]+", type = "operator" }, -- Regex (TODO: improve this, it's pretty naive and only works on some regex) @@ -206,7 +206,7 @@ syntax.add { { pattern = "%f[^%s!]%S*%$", type = "literal" }, { pattern = "%f[^%s!]%b()", type = "literal" }, -- Everything else - { pattern = "[%a_][%w_-]*", type = "symbol" }, + { pattern = "[%a_][%w_-]*", type = "symbol" }, }, symbols = symbols } From 058353fff641276576881335abc542ce80b19ae0 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 22 Jul 2024 20:44:38 +0200 Subject: [PATCH 2/2] fix: improve IPv6 matching in `language_htaccess` Also remove regex capture group that causes crashes. --- plugins/language_htaccess.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/language_htaccess.lua b/plugins/language_htaccess.lua index 69b0e689..b3d48b2f 100644 --- a/plugins/language_htaccess.lua +++ b/plugins/language_htaccess.lua @@ -187,7 +187,7 @@ syntax.add { -- IPs { pattern = "%d+%.%d+%.%d+%.%d+", type = "keyword2" }, { pattern = "%d+%.%d+%.%d+%.%d+/%d+", type = "keyword2" }, - { regex = "([a-f0-9:]+:+)+[a-f0-9]+", type = "keyword2" }, + { regex = [[(?:[a-fA-F0-9]*:)+(?:[a-fA-F0-9]+|:)(?:\/[0-9]+)?]], type = "keyword2" }, -- Emails { pattern = "%w+@%w+%.%w+", type = "keyword2" }, -- Rewrite option sections