From 49cc36ef31ccf752bec4d594c21bc75467ac2126 Mon Sep 17 00:00:00 2001 From: dreamer Date: Tue, 14 Apr 2026 08:24:34 +0200 Subject: [PATCH] use custom escape function --- code/handlers/roothandler.lua | 4 +--- code/hotmixes/utils.lua | 11 ++++++++++- code/views/root.etlua | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/code/handlers/roothandler.lua b/code/handlers/roothandler.lua index 79b540f..7425ca4 100644 --- a/code/handlers/roothandler.lua +++ b/code/handlers/roothandler.lua @@ -1,6 +1,4 @@ -local to_json = require("lapis.util").to_json local autoload = require("lapis.util").autoload -local escape = require("lapis.util").escape local config = require("lapis.config") local hotmixes = autoload("hotmixes") @@ -18,7 +16,7 @@ local function Roothandler(self) self.images = stuff.images self.latestpath = latest_path self.latestname = latest_name - self.functions = { escape = escape } + self.functions = { hotesc = hotmixes.utils.hotesc } if self.titles['url'] == "panamaracing.club" then return { render = "root", layout = require "views.prc_layout" } diff --git a/code/hotmixes/utils.lua b/code/hotmixes/utils.lua index 4361468..a8252a3 100644 --- a/code/hotmixes/utils.lua +++ b/code/hotmixes/utils.lua @@ -30,6 +30,10 @@ local type_allowed = { jpg=true, jpeg=true, png=true, gif=true, mp3=true, flac=t local utils = {} +local function hotesc ( str ) + return escape(str):gsub("%%2f", "/"):gsub("%%2d", "-"):gsub("%%2e", ".") +end + utils['request_path'] = request_path utils['data_path'] = data_path @@ -84,12 +88,17 @@ utils['these_files'] = function( path ) return stuff end +utils['hotesc'] = function( str ) + return hotesc(str) +end + utils['these_latest'] = function( path ) -- list last 10 modified files in our directory local latest_path, latest_name = {}, {} 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 result = "" diff --git a/code/views/root.etlua b/code/views/root.etlua index a7aa5b6..20216b6 100644 --- a/code/views/root.etlua +++ b/code/views/root.etlua @@ -10,13 +10,13 @@ <% for i, dir in ipairs(dirs) do %>
- " class="djsection"><%= dir %> + <%= dir %>
<% end %>
<% for i, file in ipairs(files) do %> - "> + <%= file %>