diff options
| author | Diego Nehab <diego.nehab@gmail.com> | 2017-03-20 17:01:30 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-20 17:01:30 -0300 |
| commit | ff1a447b4d8a635b7e15f11c00de34501c8672b2 (patch) | |
| tree | 052eb1122eec408b484c432a0b26e7af56f1791e | |
| parent | 47e644031fed0ced1066ff843c9b42d45b54042d (diff) | |
| parent | 44fb9e911281a2ff2c032cd20959ad91a1f470b4 (diff) | |
| download | luasocket-ff1a447b4d8a635b7e15f11c00de34501c8672b2.tar.gz luasocket-ff1a447b4d8a635b7e15f11c00de34501c8672b2.tar.bz2 luasocket-ff1a447b4d8a635b7e15f11c00de34501c8672b2.zip | |
Merge pull request #210 from Lord-Helmchen/patch-1
make protect_segment in url.lua rfc compliant
| -rw-r--r-- | src/url.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/url.lua b/src/url.lua index 1e5a3f6..d61111e 100644 --- a/src/url.lua +++ b/src/url.lua | |||
| @@ -49,7 +49,7 @@ local function make_set(t) | |||
| 49 | return s | 49 | return s |
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | -- these are allowed withing a path segment, along with alphanum | 52 | -- these are allowed within a path segment, along with alphanum |
| 53 | -- other characters must be escaped | 53 | -- other characters must be escaped |
| 54 | local segment_set = make_set { | 54 | local segment_set = make_set { |
| 55 | "-", "_", ".", "!", "~", "*", "'", "(", | 55 | "-", "_", ".", "!", "~", "*", "'", "(", |
| @@ -59,7 +59,7 @@ local segment_set = make_set { | |||
| 59 | local function protect_segment(s) | 59 | local function protect_segment(s) |
| 60 | return string.gsub(s, "([^A-Za-z0-9_])", function (c) | 60 | return string.gsub(s, "([^A-Za-z0-9_])", function (c) |
| 61 | if segment_set[c] then return c | 61 | if segment_set[c] then return c |
| 62 | else return string.format("%%%02x", string.byte(c)) end | 62 | else return string.format("%%%02X", string.byte(c)) end |
| 63 | end) | 63 | end) |
| 64 | end | 64 | end |
| 65 | 65 | ||
