escape url paths

This commit is contained in:
dreamer 2026-03-30 12:17:07 +02:00
parent ef04458cd8
commit dc196fb621
4 changed files with 11 additions and 10 deletions

View File

@ -18,7 +18,7 @@ local function Latesthandler(self)
local file_data = {}
file_data["name"] = latest_name[i]
file_data["url"] = data_path .. escape(file)
file_data["url"] = data_path .. file
table.insert(latest_json["files"], file_data)
end

View File

@ -1,5 +1,6 @@
local lfs = require 'lfs_ffi'
local config = require("lapis.config").get()
local escape = require("lapis.util").escape
-- setup
@ -63,17 +64,17 @@ utils['these_files'] = function( path )
if utils.match_ext( file, type_image ) then
table.insert( images, file )
elseif utils.match_ext( file, type_media ) then
table.insert( files, file )
table.insert( files, {sane=escape(file), file=file} )
end
elseif lfs.attributes( path .. file, "mode" ) == "directory" then
table.insert( dirs, file )
table.insert( dirs, {sane=escape(file), dir=file} )
end
end
end
table.sort( images )
table.sort( files )
table.sort( dirs )
-- table.sort( files )
-- table.sort( dirs )
local stuff = {
files = files,
@ -88,7 +89,7 @@ utils['these_latest'] = function( path )
local latest_path, latest_name = {}, {}
for i, file_path in ipairs( utils.latest_files( path ) ) do
table.insert( latest_path, file_path)
table.insert( latest_path, escape(file_path))
local temp = ""
local result = ""

View File

@ -31,7 +31,7 @@
<br>
<h1 class="h1">Latest uploads:</h1>
<% for i, file in ipairs(latestpath) do %>
<a class="amixlink" href="<%= '/data/' .. titles.url .. '/' .. file:gsub("#", "%%23") %>">
<a class="amixlink" href="<%= '/data/' .. titles.url .. '/' .. file %>">
<span class="mixlink"><%= latestname[i] %></span>
</a>
</br>

View File

@ -10,14 +10,14 @@
<% for i, dir in ipairs(dirs) do %>
<br>
<a href="<%= uri .. dir %>" class="djsection"><span><%= dir %></span></a>
<a href="<%= uri .. dir["sane"] %>" class="djsection"><span><%= dir["dir"] %></span></a>
<br>
<% end %>
<br>
<% for i, file in ipairs(files) do %>
<a class="amixlink" href="<%= path .. file:gsub("#", "%%23") %>">
<span class="mixlink"><%= file %></span>
<a class="amixlink" href="<%= path .. file["sane"] %>">
<span class="mixlink"><%= file["file"] %></span>
</a>
<br>
<% end %>