Welcome! Log In Create A New Profile

Advanced

[PATCH 09 of 12] Win32: non-ASCII names support in ngx_rename_file()

Maxim Dounin
January 12, 2023 04:40PM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1673548982 -10800
# Thu Jan 12 21:43:02 2023 +0300
# Node ID 718bf1f036e6e00f09bb4569b124540ed3153392
# Parent d680dedf87fb861f6265218b5d53b49e951947e0
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).

diff -r d680dedf87fb -r 718bf1f036e6 src/os/win32/ngx_files.c
--- a/src/os/win32/ngx_files.c Thu Jan 12 21:42:58 2023 +0300
+++ b/src/os/win32/ngx_files.c Thu Jan 12 21:43:02 2023 +0300
@@ -242,6 +242,61 @@ failed:
}


+ngx_int_t
+ngx_rename_file(u_char *from, u_char *to)
+{
+ long rc;
+ size_t len;
+ u_short *fu, *tu;
+ ngx_err_t err;
+ u_short utf16f[NGX_UTF16_BUFLEN];
+ u_short utf16t[NGX_UTF16_BUFLEN];
+
+ len = NGX_UTF16_BUFLEN;
+ fu = ngx_utf8_to_utf16(utf16f, from, &len, 0);
+
+ if (fu == NULL) {
+ return NGX_FILE_ERROR;
+ }
+
+ rc = NGX_FILE_ERROR;
+ tu = NULL;
+
+ if (ngx_win32_check_filename(fu, len, 0) != NGX_OK) {
+ goto failed;
+ }
+
+ len = NGX_UTF16_BUFLEN;
+ tu = ngx_utf8_to_utf16(utf16t, to, &len, 0);
+
+ if (tu == NULL) {
+ goto failed;
+ }
+
+ if (ngx_win32_check_filename(tu, len, 1) != NGX_OK) {
+ goto failed;
+ }
+
+ rc = MoveFileW(fu, tu);
+
+failed:
+
+ if (fu != utf16f) {
+ err = ngx_errno;
+ ngx_free(fu);
+ ngx_set_errno(err);
+ }
+
+ if (tu && tu != utf16t) {
+ err = ngx_errno;
+ ngx_free(tu);
+ ngx_set_errno(err);
+ }
+
+ return rc;
+}
+
+
ngx_err_t
ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_log_t *log)
{
diff -r d680dedf87fb -r 718bf1f036e6 src/os/win32/ngx_files.h
--- a/src/os/win32/ngx_files.h Thu Jan 12 21:42:58 2023 +0300
+++ b/src/os/win32/ngx_files.h Thu Jan 12 21:43:02 2023 +0300
@@ -127,7 +127,7 @@ ngx_int_t ngx_delete_file(u_char *name);
#define ngx_delete_file_n "DeleteFile()"


-#define ngx_rename_file(o, n) MoveFile((const char *) o, (const char *) n)
+ngx_int_t ngx_rename_file(u_char *from, u_char *to);
#define ngx_rename_file_n "MoveFile()"
ngx_err_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_log_t *log);

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 00 of 12] win32 non-ASCII names support fixes

Maxim Dounin 806 January 12, 2023 04:40PM

[PATCH 03 of 12] Win32: non-ASCII directory names support in ngx_getcwd()

Maxim Dounin 179 January 12, 2023 04:40PM

Re: [PATCH 03 of 12] Win32: non-ASCII directory names support in ngx_getcwd()

Sergey Kandaurov 110 February 17, 2023 10:04AM

Re: [PATCH 03 of 12] Win32: non-ASCII directory names support in ngx_getcwd()

Maxim Dounin 167 February 19, 2023 12:24PM

Re: [PATCH 03 of 12] Win32: non-ASCII directory names support in ngx_getcwd()

Sergey Kandaurov 107 February 22, 2023 11:02AM

[PATCH 01 of 12] Win32: non-ASCII names support in autoindex (ticket #458)

Maxim Dounin 132 January 12, 2023 04:40PM

Re: [PATCH 01 of 12] Win32: non-ASCII names support in autoindex (ticket #458)

Sergey Kandaurov 120 February 17, 2023 09:40AM

Re: [PATCH 01 of 12] Win32: non-ASCII names support in autoindex (ticket #458)

Maxim Dounin 106 February 19, 2023 12:18PM

Re: [PATCH 01 of 12] Win32: non-ASCII names support in autoindex (ticket #458)

Sergey Kandaurov 111 February 22, 2023 10:40AM

[PATCH 02 of 12] Win32: non-ASCII names support in "include" with wildcards

Maxim Dounin 139 January 12, 2023 04:40PM

Re: [PATCH 02 of 12] Win32: non-ASCII names support in "include" with wildcards

Sergey Kandaurov 136 February 17, 2023 09:54AM

Re: [PATCH 02 of 12] Win32: non-ASCII names support in "include" with wildcards

Maxim Dounin 155 February 19, 2023 12:20PM

Re: [PATCH 02 of 12] Win32: non-ASCII names support in "include" with wildcards

Sergey Kandaurov 113 February 22, 2023 10:50AM

[PATCH 04 of 12] Win32: non-ASCII directory names support in ngx_create_dir()

Maxim Dounin 143 January 12, 2023 04:40PM

Re: [PATCH 04 of 12] Win32: non-ASCII directory names support in ngx_create_dir()

Sergey Kandaurov 131 February 17, 2023 10:14AM

[PATCH 05 of 12] Win32: non-ASCII directory names support in ngx_delete_dir()

Maxim Dounin 120 January 12, 2023 04:40PM

Re: [PATCH 05 of 12] Win32: non-ASCII directory names support in ngx_delete_dir()

Sergey Kandaurov 119 February 17, 2023 10:14AM

[PATCH 06 of 12] Win32: reworked ngx_win32_rename_file() to check errors

Maxim Dounin 147 January 12, 2023 04:40PM

[PATCH 07 of 12] Win32: reworked ngx_win32_rename_file() to use nginx wrappers

Maxim Dounin 118 January 12, 2023 04:40PM

[PATCH 09 of 12] Win32: non-ASCII names support in ngx_rename_file()

Maxim Dounin 163 January 12, 2023 04:40PM

[PATCH 10 of 12] Win32: non-ASCII names support in ngx_open_tempfile()

Maxim Dounin 125 January 12, 2023 04:40PM

[PATCH 08 of 12] Win32: non-ASCII names support in ngx_delete_file()

Maxim Dounin 121 January 12, 2023 04:40PM

[PATCH 12 of 12] Win32: non-ASCII names in ngx_fs_bsize(), ngx_fs_available()

Maxim Dounin 140 January 12, 2023 04:40PM

[PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Maxim Dounin 143 January 12, 2023 04:40PM

Re: [PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Sergey Kandaurov 114 February 17, 2023 10:18AM

Re: [PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Maxim Dounin 117 February 19, 2023 12:24PM

Re: [PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Sergey Kandaurov 108 February 22, 2023 11:02AM

Re: [PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Maxim Dounin 112 February 23, 2023 01:48PM

Re: [PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Sergey Kandaurov 118 February 24, 2023 05:42AM

Re: [PATCH 11 of 12] Win32: fixed ngx_fs_bsize() for symlinks

Sergey Kandaurov 120 March 21, 2023 07:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 119
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready