1 diff -urN php-4_2_0RC3.org/main/SAPI.c php-4_2_0RC3/main/SAPI.c
2 --- php-4_2_0RC3.org/main/SAPI.c Sat Apr 13 01:18:30 2002
3 +++ php-4_2_0RC3/main/SAPI.c Sat Apr 13 01:38:42 2002
6 #include "ext/standard/php_string.h"
7 #include "ext/standard/pageinfo.h"
8 -#if HAVE_PCRE || HAVE_BUNDLED_PCRE
9 -#include "ext/pcre/php_pcre.h"
15 } else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */
17 char *result, *newheader;
18 -#if HAVE_PCRE || HAVE_BUNDLED_PCRE
20 - char *ptr = colon_offset+1;
21 - int ptr_len=0, result_len = 0;
24 SG(sapi_headers).http_response_code = 401; /* authentication-required */
25 -#if HAVE_PCRE || HAVE_BUNDLED_PCRE
27 - myuid = php_getuid();
29 - ptr_len = strlen(ptr);
30 - MAKE_STD_ZVAL(repl_temp);
31 - Z_TYPE_P(repl_temp) = IS_STRING;
32 - Z_STRVAL_P(repl_temp) = emalloc(32);
33 - Z_STRLEN_P(repl_temp) = sprintf(Z_STRVAL_P(repl_temp), "realm=\"\\1-%ld\"", myuid);
34 - /* Modify quoted realm value */
35 - result = php_pcre_replace("/realm=\"(.*?)\"/i", 16,
38 - 0, &result_len, -1 TSRMLS_CC);
39 - if(result_len==ptr_len) {
41 - sprintf(Z_STRVAL_P(repl_temp), "realm=\\1-%ld\\2", myuid);
42 - /* modify unquoted realm value */
43 - result = php_pcre_replace("/realm=([^\\s]+)(.*)/i", 21,
46 - 0, &result_len, -1 TSRMLS_CC);
47 - if(result_len==ptr_len) {
48 - char *lower_temp = estrdup(ptr);
52 - php_strtolower(lower_temp,strlen(lower_temp));
53 - /* If there is no realm string at all, append one */
54 - if(!strstr(lower_temp,"realm")) {
56 - conv_len = sprintf(conv_temp," realm=\"%ld\"",myuid);
57 - result = emalloc(ptr_len+conv_len+1);
58 - result_len = ptr_len+conv_len;
59 - memcpy(result, ptr, ptr_len);
60 - memcpy(result+ptr_len, conv_temp, conv_len);
61 - *(result+ptr_len+conv_len) = '\0';
66 - newlen = sizeof("WWW-Authenticate: ") + result_len;
67 - newheader = emalloc(newlen+1);
68 - sprintf(newheader,"WWW-Authenticate: %s", result);
70 - sapi_header.header = newheader;
71 - sapi_header.header_len = newlen;
73 - efree(Z_STRVAL_P(repl_temp));
81 sapi_header.header_len = newlen;
86 if (sapi_header.header==header_line) {