project Websites / videos.bentasker.co.uk avatar

Websites / videos.bentasker.co.uk: 68cc737c




VID-11 URL unencode the referrer taken from the query string before using in comparisons

VID-11 URL unencode the referrer taken from the query string before using in comparisons

Commit 68cc737c.

Authored 2019-04-16T18:13:20.000+01:00 by B Tasker in project Websites / videos.bentasker.co.uk

+14 lines -3 lines

Changes

diff --git a/resources/tokenisation/minter/token_gen.lua b/resources/tokenisation/minter/token_gen.lua
--- a/resources/tokenisation/minter/token_gen.lua
+++ b/resources/tokenisation/minter/token_gen.lua
# @@ -67,6 +67,17 @@ function strSplit(delim,str)
# return t
# end
#
# +local hex_to_char = function(x)
# + -- From https://stackoverflow.com/questions/20282054/how-to-urldecode-a-request-uri-string-in-lua
# + return string.char(tonumber(x, 16))
# +end
# +
# +local unescape = function(url)
# + -- From https://stackoverflow.com/questions/20282054/how-to-urldecode-a-request-uri-string-in-lua
# + return url:gsub("%%(%x%x)", hex_to_char)
# +end
# +
# +
#
#
# local function sendSuccessful(tok,expires,debug)
# @@ -151,7 +162,7 @@ end
# -- Function main
#
# -- get some details from the request
# -local referer = ngx.var.arg_ref
# +local referer = unescape(ngx.var.arg_ref)
# -- local referer = 'https://snippets.bentasker.co.uk/foobar' -- for offline testing only
#
# local vidpath = ngx.var.arg_vidpath
# @@ -163,8 +174,8 @@ local ip = ngx.var.remote_addr
#
#
# -- Grab the HTTP referrer header if present
# --- local httpref = ngx.var.http_referer
# -local httpref = 'https://snippets.bentasker.co.uk/foobar'
# +local httpref = ngx.var.http_referer
# +-- local httpref = 'https://snippets.bentasker.co.uk/foobar' -- for offline testing only
#
#
#
#