1 diff -urN php-4.1.1.orig/main/SAPI.c php-4.1.1/main/SAPI.c
2 --- php-4.1.1.orig/main/SAPI.c Mon Feb 4 13:07:01 2002
3 +++ php-4.1.1/main/SAPI.c Mon Feb 4 13:29:44 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_STRVAL_P(repl_temp) = emalloc(32);
32 - Z_STRLEN_P(repl_temp) = sprintf(Z_STRVAL_P(repl_temp), "realm=\"\\1-%ld\"", myuid);
33 - /* Modify quoted realm value */
34 - result = php_pcre_replace("/realm=\"(.*?)\"/i", 16,
37 - 0, &result_len, -1 TSRMLS_CC);
38 - if(result_len==ptr_len) {
40 - sprintf(Z_STRVAL_P(repl_temp), "realm=\\1-%ld\\2", myuid);
41 - /* modify unquoted realm value */
42 - result = php_pcre_replace("/realm=([^\\s]+)(.*)/i", 21,
45 - 0, &result_len, -1 TSRMLS_CC);
46 - if(result_len==ptr_len) {
47 - char *lower_temp = estrdup(ptr);
51 - php_strtolower(lower_temp,strlen(lower_temp));
52 - /* If there is no realm string at all, append one */
53 - if(!strstr(lower_temp,"realm")) {
55 - conv_len = sprintf(conv_temp," realm=\"%ld\"",myuid);
56 - result = emalloc(ptr_len+conv_len+1);
57 - result_len = ptr_len + conv_len;
58 - memcpy(result, ptr, ptr_len);
59 - memcpy(result+ptr_len, conv_temp, conv_len);
60 - *(result+ptr_len+conv_len) = '\0';
65 - newlen = sizeof("WWW-Authenticate: ") + result_len;
66 - newheader = emalloc(newlen+1);
67 - sprintf(newheader,"WWW-Authenticate: %s", result);
69 - sapi_header.header = newheader;
70 - sapi_header.header_len = newlen;
72 - efree(Z_STRVAL_P(repl_temp));
80 sapi_header.header_len = newlen;
85 if (sapi_header.header==header_line) {