Mercurial > prosody-modules
comparison mod_http_oauth2/mod_http_oauth2.lua @ 5957:e8bf46a7bb27
mod_http_oauth2: Ensure URL ports are integer in correct range
LuaSocket is weird and thinks ports should be strings
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 29 Aug 2024 18:03:23 +0200 |
| parents | 97375a78d2b5 |
| children | 5f8a306c8306 |
comparison
equal
deleted
inserted
replaced
| 5956:97375a78d2b5 | 5957:e8bf46a7bb27 |
|---|---|
| 30 | 30 |
| 31 local function strict_url_parse(urlstr) | 31 local function strict_url_parse(urlstr) |
| 32 local url_parts = url.parse(urlstr); | 32 local url_parts = url.parse(urlstr); |
| 33 if not url_parts then return url_parts; end | 33 if not url_parts then return url_parts; end |
| 34 if url_parts.userinfo then return false; end | 34 if url_parts.userinfo then return false; end |
| 35 if url_parts.port then | |
| 36 local port = tonumber(url_parts.port); | |
| 37 if not port then return false; end | |
| 38 if not (port > 0 and port <= 0xffff) then return false; end | |
| 39 if port ~= math.floor(port) then return false; end | |
| 40 end | |
| 35 return url_parts; | 41 return url_parts; |
| 36 end | 42 end |
| 37 | 43 |
| 38 local function strict_formdecode(query) | 44 local function strict_formdecode(query) |
| 39 if not query then | 45 if not query then |
