Skip to content

Commit 4bcb983

Browse files
committed
fix: bypass parsing of all comment lines and properly handle empty [QSA] flag
This fixes #4.
1 parent 0fb7bc7 commit 4bcb983

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

htaccess.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,10 @@ local stat_blocks_used = {}
815815
for statement in htaccess:gmatch('[^\r\n]+') do
816816
-- Trim leading whitespace
817817
statement = statement:gsub("^%s*", "");
818-
if statement:sub(1,1) == '<' then
818+
819+
if statement:sub(1,1) == '#' then
820+
-- Comment, so ignore it
821+
elseif statement:sub(1,1) == '<' then
819822
-- handle blocks
820823
if statement:sub(2,2) ~= '/' then
821824
-- opening tag <...>
@@ -989,6 +992,7 @@ for statement in htaccess:gmatch('[^\r\n]+') do
989992
pop_ctx()
990993
end
991994
end
995+
992996
else
993997
local instruction = statement:match('^[^%s]+')
994998
if instruction then
@@ -1209,11 +1213,9 @@ if get_cdir('rewrite') and #parsed_rewriterules > 0 then
12091213
elseif flag == 'qsa' or flag == 'qsappend' then -- [QSA]
12101214
local qs = relative_uri:match('%?.*')
12111215
if qs then
1212-
local new_qs = dst:match('%?.*')
1216+
local new_qs = dst:match('%?.*')
12131217
if new_qs then
12141218
dst = dst:gsub('%?.*', '', 1)..qs..'&'..new_qs:sub(2)
1215-
else
1216-
dst = dst..new_qs
12171219
end
12181220
end
12191221
elseif flag == 'qsd' or flag == 'qsdiscard' then -- [QSD]

0 commit comments

Comments
 (0)