3 Commits

Author SHA1 Message Date
dreamer 49cc36ef31 use custom escape function 2026-04-14 08:24:34 +02:00
dreamer fe70315a63 un-escape more chars 2026-04-13 21:35:46 +02:00
dreamer 3aec58719b don't remove leading slash 2026-04-13 21:27:08 +02:00
3 changed files with 14 additions and 7 deletions
+2 -4
View File
@@ -1,6 +1,4 @@
local to_json = require("lapis.util").to_json
local autoload = require("lapis.util").autoload local autoload = require("lapis.util").autoload
local escape = require("lapis.util").escape
local config = require("lapis.config") local config = require("lapis.config")
local hotmixes = autoload("hotmixes") local hotmixes = autoload("hotmixes")
@@ -11,14 +9,14 @@ local function Roothandler(self)
local latest_path, latest_name = hotmixes.utils.these_latest( path ) local latest_path, latest_name = hotmixes.utils.these_latest( path )
self.total = hotmixes.utils.total_files_dir( path ) self.total = hotmixes.utils.total_files_dir( path )
self.uri = hotmixes.utils.request_path:sub(2) -- remove leading slash self.uri = hotmixes.utils.request_path
self.path = '/data/' .. self.titles.url .. hotmixes.utils.request_path self.path = '/data/' .. self.titles.url .. hotmixes.utils.request_path
self.dirs = stuff.dirs self.dirs = stuff.dirs
self.files = stuff.files self.files = stuff.files
self.images = stuff.images self.images = stuff.images
self.latestpath = latest_path self.latestpath = latest_path
self.latestname = latest_name self.latestname = latest_name
self.functions = { escape = escape } self.functions = { hotesc = hotmixes.utils.hotesc }
if self.titles['url'] == "panamaracing.club" then if self.titles['url'] == "panamaracing.club" then
return { render = "root", layout = require "views.prc_layout" } return { render = "root", layout = require "views.prc_layout" }
+10 -1
View File
@@ -30,6 +30,10 @@ local type_allowed = { jpg=true, jpeg=true, png=true, gif=true, mp3=true, flac=t
local utils = {} local utils = {}
local function hotesc ( str )
return escape(str):gsub("%%2f", "/"):gsub("%%2d", "-"):gsub("%%2e", ".")
end
utils['request_path'] = request_path utils['request_path'] = request_path
utils['data_path'] = data_path utils['data_path'] = data_path
@@ -84,12 +88,17 @@ utils['these_files'] = function( path )
return stuff return stuff
end end
utils['hotesc'] = function( str )
return hotesc(str)
end
utils['these_latest'] = function( path ) utils['these_latest'] = function( path )
-- list last 10 modified files in our directory -- list last 10 modified files in our directory
local latest_path, latest_name = {}, {} local latest_path, latest_name = {}, {}
for i, file_path in ipairs( utils.latest_files( path ) ) do for i, file_path in ipairs( utils.latest_files( path ) ) do
table.insert( latest_path, escape(file_path)) local escpath = hotesc(file_path)
table.insert( latest_path, escpath )
local temp = "" local temp = ""
local result = "" local result = ""
+2 -2
View File
@@ -10,13 +10,13 @@
<% for i, dir in ipairs(dirs) do %> <% for i, dir in ipairs(dirs) do %>
<br> <br>
<a href="<%- functions.escape(uri .. dir):gsub("%%2f", "/") %>" class="djsection"><span><%= dir %></span></a> <a href="<%- functions.hotesc(uri .. dir) %>" class="djsection"><span><%= dir %></span></a>
<br> <br>
<% end %> <% end %>
<br> <br>
<% for i, file in ipairs(files) do %> <% for i, file in ipairs(files) do %>
<a class="amixlink" href="<%- functions.escape(path .. file):gsub("%%2f", "/") %>"> <a class="amixlink" href="<%- functions.hotesc(path .. file) %>">
<span class="mixlink"><%= file %></span> <span class="mixlink"><%= file %></span>
</a> </a>
<br> <br>