use url encoding instead base64 (#37)

This commit is contained in:
Pierce Lally 2023-09-01 15:54:17 -04:00 committed by GitHub
parent 74f9be20b2
commit be7f5b520b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,4 @@
CFCHTTP.FileTypes = CFCHTTP.FIleTypes or {}
CFCHTTP.FileTypes = CFCHTTP.FileTypes or {}
local files, _ = file.Find( "cfc_http_restrictions/shared/filetypes/*.lua", "LUA" )
for _, f in pairs( files ) do

View File

@ -39,7 +39,7 @@ end
---@param body string
---@return boolean
function PLS.IsFileData( body )
if string.find( body, "%[playlist%]" ) then return true end
if string.find( body, "[playlist]", 1, true ) then return true end
return false
end

View File

@ -34,10 +34,20 @@ function CFCHTTP.FindURLs( text )
return urls
end
---@param url string
---@return string
function CFCHTTP.URLEncode( url )
url = url:gsub( "[^%w ]", function( c )
return string.format( "%%%02X", string.byte( c ) )
end )
return url
end
function CFCHTTP.GetRedirectURL( url )
url = string.Replace( url, "\n", "" )
url = string.Trim( url )
local b64 = util.Base64Encode( url, true )
local b64 = CFCHTTP.URLEncode( url )
return "https://gmhttp.pages.dev/redirect?url=" .. b64
end