Create an internal workaround to upload filename that contain ";" or ","
Closed this issue · 12 comments
Hello,
I think it's possible to do with the plowup hook but it would be fine if their exist an internal option for it.
Cheers.
Hello again, it seem that the upload can work if we work an a symbolic link that not contain ";" or "," do you think it can usefull to have an internal option to create a symbolic link of a file that contain ";" or "," ?
I know that we can do that with the hook but I think that is an usefull function.
Cheers.
For curiosity I checked this. I can't speak about your proposal of creating a symbolic link. curl can work with filenames containing ';' or ',' (see: man curl, search: -F, --form). However it needs intrusive changes. The core has a negligible impact on this, true changes must appear in a particular module. There are two approaches that I have invented.
First approach.
Changes in the core:
diff --git a/src/upload.sh b/src/upload.sh
index a3cd28b..fc0d812 100755
--- a/src/upload.sh
+++ b/src/upload.sh
@@ -476,10 +476,10 @@ for FILE in "${COMMAND_LINE_ARGS[@]}"; do
DESTFILE=$(pretty_name_print DATA[@] "$NAME_FORMAT")
fi
- if match '[;,]' "$DESTFILE"; then
- log_notice "Skipping ($LOCALFILE): curl can't upload filenames that contain , or ;"
- continue
- fi
+ #if match '[;,]' "$DESTFILE"; then
+ # log_notice "Skipping ($LOCALFILE): curl can't upload filenames that contain , or ;"
+ # continue
+ #fi
log_notice "Starting upload ($MODULE): $LOCALFILE"
log_notice "Destination file: $DESTFILE"
Changes in a particular module (I assume you refer to 1ficher):
diff --git a/1fichier.sh b/1fichier.sh
index aa0ba76..e51a8fc 100644
--- a/1fichier.sh
+++ b/1fichier.sh
@@ -307,7 +307,7 @@ MODULE_1FICHIER_PROBE_OPTIONS=""
--form-string "mail=$TOEMAIL" \
-F "dpass=$LINK_PASSWORD" \
-F "domain=${DOMAIN:-0}" \
- -F "file[]=@$FILE;filename=$DESTFILE" \
+ -F "file[]=@\"$FILE\";filename=\"$DESTFILE\"" \
-F "did=$DIR_ID" \
"$UPLOADURL/upload.cgi?id=$S_ID") || return
@@ -315,6 +315,7 @@ MODULE_1FICHIER_PROBE_OPTIONS=""
"$UPLOADURL/end.pl?xid=$S_ID") || return
# filename;filesize;dlid;rmid,domain;??
+ RESPONSE=$(parse . "$DESTFILE\(.*\)" <<< "$RESPONSE") || return
IFS=";" read -r _ _ DOWNLOAD_ID REMOVE_ID DOMAIN_ID _ <<< "$RESPONSE"
local -a DOMAIN_STR=('1fichier.com' 'alterupload.com' 'cjoint.net' 'desfichiers.com' \
Second approach.
Changes in the core:
diff --git a/src/upload.sh b/src/upload.sh
index a3cd28b..fa41efe 100755
--- a/src/upload.sh
+++ b/src/upload.sh
@@ -476,10 +476,13 @@ for FILE in "${COMMAND_LINE_ARGS[@]}"; do
DESTFILE=$(pretty_name_print DATA[@] "$NAME_FORMAT")
fi
- if match '[;,]' "$DESTFILE"; then
- log_notice "Skipping ($LOCALFILE): curl can't upload filenames that contain , or ;"
- continue
- fi
+ #if match '[;,]' "$DESTFILE"; then
+ # log_notice "Skipping ($LOCALFILE): curl can't upload filenames that contain , or ;"
+ # continue
+ #fi
+
+ LOCALFILE="\"$LOCALFILE\""
+ DESTFILE="\"$DESTFILE\""
log_notice "Starting upload ($MODULE): $LOCALFILE"
log_notice "Destination file: $DESTFILE"
Changes in a particular module:
diff --git a/1fichier.sh b/1fichier.sh
index aa0ba76..fe624e5 100644
--- a/1fichier.sh
+++ b/1fichier.sh
@@ -315,6 +315,7 @@ MODULE_1FICHIER_PROBE_OPTIONS=""
"$UPLOADURL/end.pl?xid=$S_ID") || return
# filename;filesize;dlid;rmid,domain;??
+ RESPONSE=$(parse . "${DESTFILE:1:${#DESTFILE}-2}\(.*\)" <<< "$RESPONSE") || return
IFS=";" read -r _ _ DOWNLOAD_ID REMOVE_ID DOMAIN_ID _ <<< "$RESPONSE"
local -a DOMAIN_STR=('1fichier.com' 'alterupload.com' 'cjoint.net' 'desfichiers.com' \
The worst thing is line IFS=";"
. We can't ignore it, that's why I removed file name with parse. Therefore we need to change a particular module. I don't know if there is another approach.
@mcrapet BTW. There should be check if "$LOCALFILE" also contains ';' or ',':
diff --git a/src/upload.sh b/src/upload.sh
index a3cd28b..da82c0a 100755
--- a/src/upload.sh
+++ b/src/upload.sh
@@ -476,7 +476,7 @@ for FILE in "${COMMAND_LINE_ARGS[@]}"; do
DESTFILE=$(pretty_name_print DATA[@] "$NAME_FORMAT")
fi
- if match '[;,]' "$DESTFILE"; then
+ if match '[;,]' "$LOCALFILE" || match '[;,]' "$DESTFILE"; then
log_notice "Skipping ($LOCALFILE): curl can't upload filenames that contain , or ;"
continue
fi
Otherwise we may get an error during uploading:
$ plowup 1fichier 'Test ;file 5MiB.zip':'Test file 5MiB.zip'
plowup: force captcha method (x11)
Starting upload (1fichier): Test ;file 5MiB.zip
Destination file: Test file 5MiB.zip
Warning: skip unknown form field: file 5MiB.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
curl: (26) couldn't open file "Test "
curl: failed with exit code 26
Failed inside 1fichier_upload() [3]
@Raziel-23
I would say curl cannot use ';' and ',' in -F because it cannot escape characters (I think).
I tried to upload ',' or ';' with the bash script www.multiup.org/en/upload-softwares withtout any succes (I tried same to escape ; or , with \ in the bash script).
So I think the easier way is too have a command to create symbolic if the local file contain ';' or ','.
@kidburglar
This is a current curl limitation, you can't use filenames with ';' or ',' unless they are quoted by double-quotes. Maybe this will change in a future, but I'm very much doubt.
This is my personal opinion, but I don't think this option would achieve more then a simple renaming script. In both cases you will get uploaded filenames without ';' and ',', so I think it is not worth the effort.
It's possible that some files may not be rename and so yes we can do a symbolic link with a script or copy the file with another name but I think it can be an usefull function.
Uploading to 1fichier a filename containing a coma:
$ plowup 1fichier test1,test2
Skipping (test1,test2): curl can't upload filenames that contain , or ;
$ ln test1,test2 tmp
$ plowup 1fichier tmp:test1,test2
Starting upload (1fichier): tmp
Destination file: test1,test2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1136k 0 4339 100 1131k 2763 720k 0:00:01 0:00:01 --:--:-- 720k
#DEL https://1fichier.com/remove/51a9gaazj9/Vl2IR
https://1fichier.com/?51a9gaazj9
$ rm tmp
I just try but maybe I did something wrong
$ plowmod -u
$ echo "something" > 'test1,test2'
$ ln test1,test2 tmp
$ plowup --no-plowsharerc 1fichier tmp:test1,test2
Starting upload (1fichier): tmp
Destination file: test1,test2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (26) couldn't open file "test2"
curl: failed with exit code 26
Failed inside 1fichier_upload() [3]`
@kidburglar: You must update plowshare core not modules!
Ah yes sorry my fault.
It work nice, maybe an option to create / remove the symlink too ^^ ?
If not I will look to do it with the hooks, no problems.
The issue that you can share same inode on the same filesystems. Plowshare core is not writing anything in the location of source files. Only temp directory is used (see --temp-directory
switch, defaults to /tmp
).
But this should work using symbolic link (not physical link).
@kidburglar update plowshare core again.
$ plowup 1fichier 'd,d,d,d'
should work.
Work perfectly, thanks !