diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2018-04-03 21:00:15 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2018-04-03 21:00:15 +0200 |
commit | e2652ce02f6d743940c846f6faf263054e018a4b (patch) | |
tree | 0141ea0761b7fe8521ae25fad9c42be6add0d5d9 /src | |
parent | Remove 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')
-rw-r--r-- | src/mod_http_upload.erl | 18 |
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(). |