Index: t3lib/class.gzip_encode.php
===================================================================
--- t3lib/class.gzip_encode.php	(Revision 2201)
+++ t3lib/class.gzip_encode.php	(Arbeitskopie)
@@ -15,6 +15,9 @@
  *
  * Changes compared to the upstream version:
  *
+ * 2007-03-27  Oliver Hader  <oh@inpublica.de>
+ *  - Fixed bug #4623: Content encoding with x-gzip not allowed
+ *  - Fixed missing comments and line formats (cleaner)
  * 2005-12-09  Peter Niederlag  <peter@niederlag.de>
  *	- Fixed bug #1976: PHP5 type-conversion of string 'true' and boolean
  *
@@ -22,8 +25,34 @@
  *
  * @author	Sandy McArthur, Jr. <leknor@leknor.com>
  */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   53: class gzip_encode
+ *  193:     function gzip_encode($level = 3, $debug=false, $outputCompressedSizes=false)
+ *  268:     function gzip_accepted()
+ *  317:     function get_complevel()
+ *  342:     function linux_loadavg()
+ *  363:     function freebsd_loadavg()
+ *
+ * TOTAL FUNCTIONS: 5
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+
+
+/**
+ * gzip_encode - a class to gzip encode php output
+ *
+ * @author		Sandy McArthur, Jr. <Leknor@Leknor.com>
+ * @package		TYPO3
+ * @subpackage	t3lib
+ */
 class gzip_encode {
-    /*
+	/**
      * gzip_encode - a class to gzip encode php output
      *
      * By Sandy McArthur, Jr. <Leknor@Leknor.com>
@@ -139,7 +168,7 @@
     var $size;		// size of the uncompressed content
     var $gzsize;	// size of the compressed content
 
-    /*
+	/**
      * gzip_encode constructor - gzip encodes the current output buffer
      * if the browser supports it.
      *
@@ -156,8 +185,13 @@
      * You can specify one of the following for the second argument:
      *	true:	Don't actully output the compressed form but run as if it
      *		had. Used for debugging.
+	 *
+	 * @param	integer		$level: Define the level of compression between 0 (none) and 9 (best compression)
+	 * @param	boolean		$debug: If true, no data will be outputted (default: false)
+	 * @param	boolean		$outputCompressedSizes: If true, the original and compressed size appended as HTML (default: false)
+	 * @return	void
      */
-    function gzip_encode($level = 3, $debug = false, $outputCompressedSizes=0) {
+	function gzip_encode($level = 3, $debug=false, $outputCompressedSizes=false) {
 	if (!function_exists('gzcompress')) {
 	    trigger_error('gzcompress not found, ' .
 		    'zlib needs to be installed for gzip_encode',
@@ -215,9 +249,8 @@
     }
 
 
-    /*
+	/**
      * gzip_accepted() - Test headers for Accept-Encoding: gzip
-     *
      * Returns: if proper headers aren't found: false
      *          if proper headers are found: 'gzip' or 'x-gzip'
      *
@@ -228,13 +261,17 @@
      *    }
      *  note the double colon syntax, I don't know where it is documented but
      *  somehow it got in my brain.
+	 *
+	 * @return	mixed		Returns 'gzip' if the client browser accepts gzip encoding, otherwise false
      */
     function gzip_accepted() {
-	if (strpos(getenv("HTTP_ACCEPT_ENCODING"), 'gzip') === false) return false;
-	if (strpos(getenv("HTTP_ACCEPT_ENCODING"), 'x-gzip') === false) {
+			// Checks, if the accepted encoding supports gzip or x-gzip.
+			// Furthermore a qvalue check is done. "gzip;q=0" means to gzip accepted at all.
+		$acceptEncoding = $GLOBALS['_SERVER']['HTTP_ACCEPT_ENCODING'];
+		if (preg_match('/(^|,\s*)(x-)?gzip(;q=(\d(\.\d+)?))?(,|$)/', $acceptEncoding, $match) && ($match[4] === '' || $match[4] > 0)) {
 	    $encoding = 'gzip';
 	} else {
-	    $encoding = 'x-gzip';
+			return false;
 	}
 
 	// Test file type. I wish I could get HTTP response headers.
@@ -263,7 +300,7 @@
 	return $encoding;
     }
 
-    /*
+	/**
      * get_complevel() - The level of compression we should use.
      *
      * Returns an int between 0 and 9 inclusive.
@@ -273,6 +310,8 @@
      *
      * Help: if you use an OS other then linux please send me code to make
      * this work with your OS - Thanks
+	 *
+	 * @return	integer		Suggests a level of compression (0..9) for the current situation
      */
     function get_complevel() {
 	$uname = posix_uname();
@@ -292,10 +331,12 @@
 	return $level;
     }
 
-    /*
+	/**
      * linux_loadavg() - Gets the max() system load average from /proc/loadavg
      *
      * The max() Load Average will be returned
+	 *
+	 * @return	float		Returns the current load average
      */
     function linux_loadavg() {
 	$buffer = "0 0 0";
@@ -308,13 +349,15 @@
 	return max((float)$load[0], (float)$load[1], (float)$load[2]);
     }
 
-    /*
+	/**
      * freebsd_loadavg() - Gets the max() system load average from uname(1)
      *
      * The max() Load Average will be returned
      *
      * I've been told the code below will work on solaris too, anyone wanna
      * test it?
+	 *
+	 * @return	float		Returns the current load average
      */
     function freebsd_loadavg() {
 	$buffer= `uptime`;
