summaryrefslogtreecommitdiff
path: root/src/mod_http_upload.erl
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2018-04-03 21:00:15 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2018-04-03 21:00:15 +0200
commite2652ce02f6d743940c846f6faf263054e018a4b (patch)
tree0141ea0761b7fe8521ae25fad9c42be6add0d5d9 /src/mod_http_upload.erl
parentRemove old hex conversion functions (diff)
mod_http_upload: Accept characters of any script
Accept all alphanumeric characters of any script in user and file names rather than replacing non-ASCII characters with underscores. However, non-alphanumeric characters are still replaced, except for "." and "-". Closes #2346.
Diffstat (limited to 'src/mod_http_upload.erl')
-rw-r--r--src/mod_http_upload.erl18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mod_http_upload.erl b/src/mod_http_upload.erl
index 0a087124..4e522e9b 100644
--- a/src/mod_http_upload.erl
+++ b/src/mod_http_upload.erl
@@ -671,21 +671,31 @@ mk_slot(Slot, #state{put_url = PutPrefix, get_url = GetPrefix}, XMLNS) ->
GetURL = str:join([GetPrefix | Slot], <<$/>>),
mk_slot(PutURL, GetURL, XMLNS);
mk_slot(PutURL, GetURL, ?NS_HTTP_UPLOAD_0) ->
- #upload_slot_0{get = GetURL, put = PutURL, xmlns = ?NS_HTTP_UPLOAD_0};
+ #upload_slot_0{get = misc:url_encode(GetURL),
+ put = misc:url_encode(PutURL),
+ xmlns = ?NS_HTTP_UPLOAD_0};
mk_slot(PutURL, GetURL, XMLNS) ->
- #upload_slot{get = GetURL, put = PutURL, xmlns = XMLNS}.
+ #upload_slot{get = misc:url_encode(GetURL),
+ put = misc:url_encode(PutURL),
+ xmlns = XMLNS}.
-spec make_user_string(jid(), sha1 | node) -> binary().
make_user_string(#jid{luser = U, lserver = S}, sha1) ->
str:sha(<<U/binary, $@, S/binary>>);
make_user_string(#jid{luser = U}, node) ->
- re:replace(U, <<"[^a-zA-Z0-9_.-]">>, <<$_>>, [global, {return, binary}]).
+ replace_special_chars(U).
-spec make_file_string(binary()) -> binary().
make_file_string(File) ->
- re:replace(File, <<"[^a-zA-Z0-9_.-]">>, <<$_>>, [global, {return, binary}]).
+ replace_special_chars(File).
+
+-spec replace_special_chars(binary()) -> binary().
+
+replace_special_chars(S) ->
+ re:replace(S, <<"[^\\p{Xan}_.-]">>, <<$_>>,
+ [unicode, global, {return, binary}]).
-spec yield_content_type(binary()) -> binary().