aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-03-02 10:09:26 +0300
committerRblSb <msrblsb@gmail.com>2025-03-03 00:51:38 +0300
commitaed0d8ed6865a3e966fa866af4b99f5d4b4d33eb (patch)
treec6c0274dc824f15855af4534747e5d36433e42a0 /src/client
parent3b22ce9b59e1e549dddbba99b90b87a1dc1fcf87 (diff)
Improve upload filename encoding
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Buttons.hx7
-rw-r--r--src/client/Utils.hx3
-rw-r--r--src/client/players/Raw.hx2
3 files changed, 7 insertions, 5 deletions
diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx
index 513133a..11b8f7c 100644
--- a/src/client/Buttons.hx
+++ b/src/client/Buttons.hx
@@ -248,7 +248,10 @@ class Buttons {
getEl("#mediaurl-upload").onclick = e -> {
Utils.browseFile((buffer, name) -> {
- if (name == null || name.length == 0) name = "video";
+ name ??= "";
+ name = ~/[?#%\/\\]/g.replace(name, "").trim();
+ if (name.length == 0) name = "video";
+ name = (window : Dynamic).encodeURIComponent(name);
// send last chunk separately to allow server file streaming while uploading
final chunkSize = 1024 * 1024 * 5; // 5 MB
@@ -258,7 +261,6 @@ class Buttons {
method: "POST",
headers: {
"content-name": name,
- "client-name": main.getName(),
},
body: lastChunk,
});
@@ -276,7 +278,6 @@ class Buttons {
final request = new XMLHttpRequest();
request.open("POST", "/upload", true);
request.setRequestHeader("content-name", name);
- request.setRequestHeader("client-name", main.getName());
request.upload.onprogress = (event:ProgressEvent) -> {
var ratio = 0.0;
diff --git a/src/client/Utils.hx b/src/client/Utils.hx
index 9217e07..f071b76 100644
--- a/src/client/Utils.hx
+++ b/src/client/Utils.hx
@@ -4,6 +4,7 @@ import haxe.io.Mime;
import js.Browser.document;
import js.Browser.navigator;
import js.Browser.window;
+import js.html.Blob;
import js.html.Element;
import js.html.FileReader;
import js.html.URL;
@@ -181,7 +182,7 @@ class Utils {
}
public static function saveFile(name:String, mime:Mime, data:String):Void {
- final blob = new js.html.Blob([data], {
+ final blob = new Blob([data], {
type: mime
});
final url = URL.createObjectURL(blob);
diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx
index f51bd9e..5a037c3 100644
--- a/src/client/players/Raw.hx
+++ b/src/client/players/Raw.hx
@@ -54,7 +54,7 @@ class Raw implements IPlayer {
var title = titleInput.value.trim();
if (title.length == 0) {
- final decodedUrl = url.urlDecode();
+ final decodedUrl = try url.urlDecode() catch (e) url;
final lastPart = decodedUrl.substr(decodedUrl.lastIndexOf("/") + 1);
if (matchName.match(lastPart)) title = matchName.matched(1);
else title = Lang.get("rawVideo");
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage