summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/basic_functions.c3
-rw-r--r--ext/standard/http_fopen_wrapper.c10
-rw-r--r--ext/standard/string.c15
-rw-r--r--ext/standard/tests/strings/ucwords_error.phpt6
-rw-r--r--ext/standard/tests/strings/ucwords_variation5.phpt25
5 files changed, 48 insertions, 11 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index c513090b19..d4c4f3962f 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2284,8 +2284,9 @@ ZEND_BEGIN_ARG_INFO(arginfo_lcfirst, 0)
ZEND_ARG_INFO(0, str)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO(arginfo_ucwords, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ucwords, 0, 0, 1)
ZEND_ARG_INFO(0, str)
+ ZEND_ARG_INFO(0, delimiters)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_strtr, 0, 0, 2)
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index f7d6fc4500..eb6cebf534 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -120,7 +120,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
char *scratch = NULL;
char *tmp = NULL;
char *ua_str = NULL;
- zval *ua_zval = NULL, *tmpzval = NULL;
+ zval *ua_zval = NULL, *tmpzval = NULL, ssl_proxy_peer_name;
int scratch_len = 0;
int body = 0;
char location[HTTP_HEADER_BLOCK_SIZE];
@@ -224,6 +224,12 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
efree(transport_string);
if (stream && use_proxy && use_ssl) {
+ /* Set peer_name or name verification will try to use the proxy server name */
+ if (!context || (tmpzval = php_stream_context_get_option(context, "ssl", "peer_name")) == NULL) {
+ ZVAL_STRING(&ssl_proxy_peer_name, resource->host);
+ php_stream_context_set_option(stream->context, "ssl", "peer_name", &ssl_proxy_peer_name);
+ }
+
smart_str header = {0};
smart_str_appendl(&header, "CONNECT ", sizeof("CONNECT ")-1);
@@ -313,7 +319,7 @@ finish:
/* enable SSL transport layer */
if (stream) {
- if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 ||
+ if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_ANY_CLIENT, NULL TSRMLS_CC) < 0 ||
php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot connect to HTTPS server through proxy");
php_stream_close(stream);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index ec9b8a02a2..5f4f360ca6 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2748,17 +2748,20 @@ PHP_FUNCTION(lcfirst)
Uppercase the first character of every word in a string */
PHP_FUNCTION(ucwords)
{
- char *str;
+ char *str, *delims = " \t\r\n\f\v";
register char *r, *r_end;
- int str_len;
+ int str_len, delims_len = 6;
+ char mask[256];
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &delims, &delims_len) == FAILURE) {
return;
}
#else
- ZEND_PARSE_PARAMETERS_START(1, 1)
+ ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STRING(str, str_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING(delims, delims_len)
ZEND_PARSE_PARAMETERS_END();
#endif
@@ -2766,12 +2769,14 @@ PHP_FUNCTION(ucwords)
RETURN_EMPTY_STRING();
}
+ php_charmask((unsigned char *)delims, delims_len, mask TSRMLS_CC);
+
ZVAL_STRINGL(return_value, str, str_len);
r = Z_STRVAL_P(return_value);
*r = toupper((unsigned char) *r);
for (r_end = r + Z_STRLEN_P(return_value) - 1; r < r_end; ) {
- if (isspace((int) *(unsigned char *)r++)) {
+ if (mask[(unsigned char)*r++]) {
*r = toupper((unsigned char) *r);
}
}
diff --git a/ext/standard/tests/strings/ucwords_error.phpt b/ext/standard/tests/strings/ucwords_error.phpt
index d79e569cc7..a01c688c4a 100644
--- a/ext/standard/tests/strings/ucwords_error.phpt
+++ b/ext/standard/tests/strings/ucwords_error.phpt
@@ -18,7 +18,7 @@ echo "\n-- Testing ucwords() function with more than expected no. of arguments -
$str = 'string_val';
$extra_arg = 10;
-var_dump( ucwords($str, $extra_arg) );
+var_dump( ucwords($str, $extra_arg, $extra_arg) );
// check if there were any changes made to $str
var_dump($str);
@@ -30,12 +30,12 @@ echo "Done\n";
-- Testing ucwords() function with Zero arguments --
-Warning: ucwords() expects exactly 1 parameter, 0 given in %s on line %d
+Warning: ucwords() expects at least 1 parameter, 0 given in %s on line %d
NULL
-- Testing ucwords() function with more than expected no. of arguments --
-Warning: ucwords() expects exactly 1 parameter, 2 given in %s on line %d
+Warning: ucwords() expects at most 2 parameters, 3 given in %s on line %d
NULL
string(10) "string_val"
Done
diff --git a/ext/standard/tests/strings/ucwords_variation5.phpt b/ext/standard/tests/strings/ucwords_variation5.phpt
new file mode 100644
index 0000000000..985df47c4a
--- /dev/null
+++ b/ext/standard/tests/strings/ucwords_variation5.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test ucwords() function : usage variations - custom delimiters
+--FILE--
+<?php
+/* Prototype : string ucwords ( string $str )
+ * Description: Uppercase the first character of each word in a string
+ * Source code: ext/standard/string.c
+*/
+
+echo "*** Testing ucwords() : usage variations ***\n";
+
+var_dump(ucwords('testing-dashed-words', '-'));
+var_dump(ucwords('test(braced)words', '()'));
+var_dump(ucwords('testing empty delimiters', ''));
+var_dump(ucwords('testing ranges', 'a..e'));
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ucwords() : usage variations ***
+string(%d) "Testing-Dashed-Words"
+string(%d) "Test(Braced)Words"
+string(%d) "Testing empty delimiters"
+string(%d) "TeSting raNgeS"
+Done