diff options
Diffstat (limited to 'lualibs-url.lua')
-rw-r--r-- | lualibs-url.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lualibs-url.lua b/lualibs-url.lua index 4624a05..7b7910f 100644 --- a/lualibs-url.lua +++ b/lualibs-url.lua @@ -79,12 +79,18 @@ setmetatable(escapes, { __index = function(t,k) return v end }) -local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most -local unescaper = Cs((escapedchar + 1)^0) +local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most +local unescaper = Cs((escapedchar + 1)^0) +local getcleaner = Cs((P("+++") / "%%2B" + P("+") / "%%20" + P(1))^1) -lpegpatterns.urlunescaped = escapedchar -lpegpatterns.urlescaper = escaper -lpegpatterns.urlunescaper = unescaper +lpegpatterns.urlunescaped = escapedchar +lpegpatterns.urlescaper = escaper +lpegpatterns.urlunescaper = unescaper +lpegpatterns.urlgetcleaner = getcleaner + +function url.unescapeget(str) + return lpegmatch(getcleaner,str) +end -- todo: reconsider Ct as we can as well have five return values (saves a table) -- so we can have two parsers, one with and one without |