Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ static void soap_smart_str_append_header_value(smart_str *dest, const zend_strin
soap_smart_str_append_header_value_ex(dest, ZSTR_VAL(value), ZSTR_LEN(value), header_name);
}

static void soap_smart_str_append_digest_username(smart_str *dest, const zend_string *username)
{
for (size_t i = 0; i < ZSTR_LEN(username); i++) {
unsigned char c = ZSTR_VAL(username)[i];
if (c < 0x20 || c == 0x7f) {
php_error_docref(NULL, E_WARNING,
"Digest username contains control characters and has been truncated");
break;
}
if (c == '"' || c == '\\') {
smart_str_appendc(dest, '\\');
}
smart_str_appendc(dest, c);
}
}

/* Proxy HTTP Authentication */
bool proxy_authentication(zval* this_ptr, smart_str* soap_headers)
{
Expand Down Expand Up @@ -812,7 +828,7 @@ bool make_http_soap_request(
make_digest(response, hash);

smart_str_append_const(&soap_headers, "Authorization: Digest username=\"");
smart_str_append(&soap_headers, Z_STR_P(login));
soap_smart_str_append_digest_username(&soap_headers, Z_STR_P(login));
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "realm", sizeof("realm")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_append_const(&soap_headers, "\", realm=\"");
Expand Down
Loading