* sanitize ob_httpetaghandler
authorMichael Wallner <mike@php.net>
Wed, 16 Feb 2005 20:08:15 +0000 (20:08 +0000)
committerMichael Wallner <mike@php.net>
Wed, 16 Feb 2005 20:08:15 +0000 (20:08 +0000)
http.c

diff --git a/http.c b/http.c
index 608586c5df337cf56bee79ea2414d3d7e56b55d6..452ec8f86a98fed4ea6e2e4e17c2a43fd6f69372 100644 (file)
--- a/http.c
+++ b/http.c
@@ -465,7 +465,9 @@ PHP_FUNCTION(http_cache_etag)
 
 /* {{{ proto string ob_httpetaghandler(string data, int mode)
  *
- * For use with ob_start(). Note that this has to be started as first output buffer.
+ * For use with ob_start(). 
+ * Note that this has to be started as first output buffer.
+ * WARNING: Don't use with http_send_*().
  */
 PHP_FUNCTION(ob_httpetaghandler)
 {
@@ -479,17 +481,18 @@ PHP_FUNCTION(ob_httpetaghandler)
 
        if (mode & PHP_OUTPUT_HANDLER_START) {
                if (HTTP_G(etag_started)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "ob_etaghandler can only be used once");
-                       RETURN_FALSE;
-               }
-               if (OG(ob_nesting_level)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be started prior to other output buffers");
-                       RETURN_FALSE;
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "ob_httpetaghandler can only be used once");
+                       RETURN_STRINGL(data, data_len, 1);
                }
                http_send_header("Cache-Control: private, must-revalidate, max-age=0");
                HTTP_G(etag_started) = 1;
        }
 
+    if (OG(ob_nesting_level) > 1) {
+        php_error_docref(NULL TSRMLS_CC, E_WARNING, "ob_httpetaghandler must be started prior to other output buffers");
+        RETURN_STRINGL(data, data_len, 1);
+    }
+    
        Z_TYPE_P(return_value) = IS_STRING;
        http_ob_etaghandler(data, data_len, &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), mode);
 }