浏览代码

Bug 2095: Cannot authenticate to WebDAV server with username containing some special characters

https://winscp.net/tracker/2095
(cherry picked from commit f1422d1f63c5e4c263945238c65155b5039e4c85)

Source commit: f9c39ec0059cccf2f390765e1de048351c8385fa
Martin Prikryl 3 年之前
父节点
当前提交
0a62b49a17
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      libs/neon/src/ne_auth.c

+ 18 - 0
libs/neon/src/ne_auth.c

@@ -961,6 +961,24 @@ static char *get_digest_h_urp(auth_session *sess, ne_buffer **errmsg,
          * cannot be sent safely. */
         char *esc = ne_strparam("UTF-8", NULL, (unsigned char *)sess->username);
 
+        #ifdef WINSCP
+        if (esc && (parms->userhash == userhash_none || parms->handler->new_creds == NULL)) {
+            const char *p;
+            int ascii = 1;
+            for (p = sess->username; *p; p++) {
+                if (((*p & ~0x7f) != 0) || (!isprint(*p) && !isspace(*p))) {
+                    ascii = 0;
+                    break;
+                }
+            }
+
+            if (ascii) {
+                ne_free(esc);
+                esc = NULL;
+            }
+        }
+        #endif
+
         if (esc) {
             if (parms->userhash == userhash_none
                 || parms->handler->new_creds == NULL) {