What about the values?

-Andrei


On Dec 6, 2006, at 5:06 PM, Ilia Alshanetsky wrote:

iliaa           Thu Dec  7 01:06:54 2006 UTC

  Modified files:
    /php-src/ext/curl   interface.c
  Log:
  Allow submission of unicode data in utf8 form


http://cvs.php.net/viewvc.cgi/php-src/ext/curl/interface.c? r1=1.98&r2=1.99&diff_format=u
Index: php-src/ext/curl/interface.c
diff -u php-src/ext/curl/interface.c:1.98 php-src/ext/curl/ interface.c:1.99
--- php-src/ext/curl/interface.c:1.98   Wed Dec  6 18:40:55 2006
+++ php-src/ext/curl/interface.c        Thu Dec  7 01:06:54 2006
@@ -16,7 +16,7 @@
+--------------------------------------------------------------------- -+
 */

-/* $Id: interface.c,v 1.98 2006/12/06 18:40:55 iliaa Exp $ */
+/* $Id: interface.c,v 1.99 2006/12/07 01:06:54 iliaa Exp $ */

 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS

@@ -1294,7 +1294,7 @@
                case CURLOPT_COOKIE:
                case CURLOPT_REFERER:
                case CURLOPT_INTERFACE:
-               case CURLOPT_KRB4LEVEL:
+               case CURLOPT_KRB4LEVEL:
                case CURLOPT_EGDSOCKET:
                case CURLOPT_CAINFO:
                case CURLOPT_CAPATH:
@@ -1433,6 +1433,7 @@
                                char             *key;
                                ulong            num_key;
                                uint             string_key_len;
+                               int              type = -1;

                                postfields = HASH_OF(*zvalue);
                                if (!postfields) {
@@ -1445,6 +1446,9 @@
zend_hash_get_current_data(postfields, (void **) &current) == SUCCESS;
                                         zend_hash_move_forward(postfields)
                                ) {
+                                       int ntype;
+                                       int l;
+                                       UErrorCode status = U_ZERO_ERROR;

                                        SEPARATE_ZVAL(current);
                                        convert_to_string_ex(current);
@@ -1453,20 +1457,25 @@
                                
                                        postval = Z_STRVAL_PP(current);

- switch (zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL)) { + ntype = zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL);
+                                       if (type == -1) {
+                                               type = ntype;
+                                       } else if (type != ntype) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Form parameters must either be all unicode or all binary");
+                                               continue;
+                                       }
+
+                                       switch (ntype) {
                                                case HASH_KEY_IS_UNICODE:
- key = zend_unicode_to_ascii(string_key.u, string_key_len TSRMLS_CC);
-                                                       if (!key) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received");
-                                                               continue;
-                                                       }
+ zend_unicode_to_string_ex(UG(utf8_conv), &key, &l, string_key.u, string_key_len, &status);
                                                        break;
                                                case HASH_KEY_IS_STRING:
                                                        key = string_key.s;
+                                                       l = string_key_len - 1;
                                                        break;
                                                case HASH_KEY_IS_LONG:
                                                        key = NULL;
-                                                       string_key_len = 0;
+                                                       l = 0;
                                                        break;
                                        }

@@ -1482,17 +1491,20 @@
                                                }
                                                error = curl_formadd(&first, 
&last,
                                                                                
         CURLFORM_COPYNAME, key,
-                                                                               
         CURLFORM_NAMELENGTH, (long)string_key_len - 1,
+                                                                               
         CURLFORM_NAMELENGTH, l,
                                                                                
         CURLFORM_FILE, postval,
                                                                                
         CURLFORM_END);
                                        } else {
                                                error = curl_formadd(&first, 
&last,
                                                                                
         CURLFORM_COPYNAME, key,
-                                                                               
         CURLFORM_NAMELENGTH, (long)string_key_len - 1,
+                                                                               
         CURLFORM_NAMELENGTH, l,
                                                                                
         CURLFORM_COPYCONTENTS, postval,
                                                                                
         CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_PP(current),
                                                                                
         CURLFORM_END);
                                        }
+                                       if (ntype == HASH_KEY_IS_UNICODE) {
+                                               efree(key);
+                                       }
                                }

                                SAVE_CURL_ERROR(ch, error);

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to