Opened 7 years ago

Closed 19 months ago

#1433 closed defect (fixed)

WebDAV module didn't convert UTF8 encode url into GBK on Windows

Reported by: ztyzbb@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.12.x
Keywords: WebDAV win32 Cc:
uname -a: Microsoft Windows [版本 10.0.15063]
nginx -V: nginx version: nginx/1.12.1

Description

I'm using Nginx as a static resource server on Windows 10. And I use php_curl to transfer file from Apache to Nginx by HTTP PUT method. When URL include Chinese in UTF8 codec like "/0/%E6%B5%B7%E6%8A%A5%E8%83%8C%E6%99%AF.jpg", the WebDAV just create a file with the UTF-8 string. But Windows use GBK to store Chinese file name. So the UTF-8 string was used as a GBK string without conversion, which lead to an incorrect name on Windows like 海报背景.jpg(correct) => 娴锋姤鑳屾櫙.jpg(incorrect).
If I use GBK encode URL "/0/%BA%A3%B1%A8%B1%B3%BE%B0.jpg"(same as the UTF-8 one in Chinese), every thing works fine, the file name on Windows is correct.
If I try to GET the GBK encode URL, the Nginx return 500 with error log: 1113: No mapping for the Unicode character exists in the target multi-byte code page. And if I use the UTF-8 encode URL, it works fine. So I can figure out the Nginx handle the GET method with a codec conversion, but PUT method not, maybe other WebDAV method not as well.

Change History (10)

comment:1 by ztyzbb@…, 7 years ago

charset has been set to utf-8 in nginx.conf.

comment:2 by ztyzbb@…, 7 years ago

nginx -V:
nginx version: nginx/1.12.1
built by cl 16.00.40219.01 for 80x86
built with OpenSSL 1.0.2l 25 May 2017
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-8.40 --with-zlib=objs.msvc8/lib/zlib-1.2.11 --with-select_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-openssl=objs.msvc8/lib/openssl-1.0.2l --with-openssl-opt=no-asm --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module

comment:3 by Maxim Dounin, 7 years ago

Keywords: win32 added
Status: newaccepted

See also #458.

comment:5 by Maxim Dounin <mdounin@…>, 21 months ago

In 8133:e0f385521c79/nginx:

Win32: non-ASCII directory names support in ngx_create_dir().

This makes it possible to create directories under prefix with non-ASCII
characters, as well as makes it possible to create directories with non-ASCII
characters when using the dav module (ticket #1433).

To ensure that the dav module operations are restricted similarly to
other file operations (in particular, short names are not allowed), the
ngx_win32_check_filename() function is used. It improved to support
checking of just dirname, and now can be used to check paths when creating
files or directories.

comment:6 by Maxim Dounin <mdounin@…>, 21 months ago

In 8134:7d60e4584d9e/nginx:

Win32: non-ASCII directory names support in ngx_delete_dir().

This makes it possible to delete directories with non-ASCII characters
when using the dav module (ticket #1433).

comment:7 by Maxim Dounin <mdounin@…>, 21 months ago

In 8136:37a184966ab3/nginx:

Win32: reworked ngx_win32_rename_file() to use nginx wrappers.

This ensures that ngx_win32_rename_file() will support non-ASCII names
when supported by the wrappers.

Notably, this is used by PUT requests in the dav module when overwriting
existing files with non-ASCII names (ticket #1433).

comment:8 by Maxim Dounin <mdounin@…>, 21 months ago

In 8137:4b06186670ed/nginx:

Win32: non-ASCII names support in ngx_delete_file().

This makes it possible to delete files with non-ASCII characters
when using the dav module (ticket #1433).

comment:9 by Maxim Dounin <mdounin@…>, 21 months ago

In 8138:96d894b38667/nginx:

Win32: non-ASCII names support in ngx_rename_file().

This makes it possible to upload files with non-ASCII characters
when using the dav module (ticket #1433).

comment:10 by Maxim Dounin, 19 months ago

Resolution: fixed
Status: acceptedclosed

Fix committed and available in nginx 1.23.4 / 1.24.0, closing this. Thanks to all involved.

Note: See TracTickets for help on using tickets.