summaryrefslogtreecommitdiff
path: root/lualibs-url.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-09-21 13:31:56 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-09-21 13:31:56 +0200
commitd96d015887e6fcbe1ca8defcec44cb794421785d (patch)
tree7e636bed27130e0b4846a7d41dfcf50e12a83492 /lualibs-url.lua
parent08563510e0f4328d9e893f17fc1fd37bac00dbc7 (diff)
downloadlualibs-d96d015887e6fcbe1ca8defcec44cb794421785d.tar.gz
sync with Context as of 2013-09-21
Diffstat (limited to 'lualibs-url.lua')
-rw-r--r--lualibs-url.lua16
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