diff --git a/assets/index.js b/assets/index.js
index df92c7c..22349ef 100644
--- a/assets/index.js
+++ b/assets/index.js
@@ -64,14 +64,16 @@ class Uploader {
upload() {
const { file, idx, name } = this;
- let url = getUrl(name);
+ const url = getUrl(name);
+ const encodedUrl = encodedStr(url);
+ const encodedName = encodedStr(name);
$uploadersTable.insertAdjacentHTML("beforeend", `
+
`;
}
@@ -197,7 +204,7 @@ function addPath(file, index) {
${getSvg(file.path_type)}
- ${file.name}
+ ${encodedName}
|
${formatMtime(file.mtime)} |
${formatSize(file.size).join(" ")} |
@@ -333,7 +340,14 @@ function formatPercent(precent) {
}
}
+function encodedStr(rawStr) {
+ return rawStr.replace(/[\u00A0-\u9999<>\&]/g, function(i) {
+ return ''+i.charCodeAt(0)+';';
+ });
+}
+
function ready() {
+ document.title = `Index of ${DATA.href} - Dufs`;
$pathsTable = document.querySelector(".paths-table")
$pathsTableBody = document.querySelector(".paths-table tbody");
$uploadersTable = document.querySelector(".uploaders-table");
diff --git a/src/server.rs b/src/server.rs
index 06cd0f8..9417b43 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -692,7 +692,7 @@ impl Server {
paths.sort_unstable();
let href = format!("/{}", normalize_path(path.strip_prefix(&self.args.path)?));
let data = IndexData {
- href: href.clone(),
+ href,
uri_prefix: self.args.uri_prefix.clone(),
paths,
allow_upload: self.args.allow_upload,
@@ -705,14 +705,13 @@ impl Server {
"__SLOT__",
&format!(
r#"
-
Index of {} - Dufs
"#,
- href, INDEX_CSS, data, INDEX_JS
+ INDEX_CSS, data, INDEX_JS
),
);
res.headers_mut()