#25 PHPproxy tries to rewrite images inside images

open
nobody
None
5
2006-03-24
2006-03-24
No

it only affects performance because it cannot find any
url inside images,etc but makes PHPproxy slower

in PHPProxy.class.php in the set_response function. The
following if clause that is used to decide if it will
rewrite links or it will passthru it is flawed. If you
add the two log statement you'll see that it tries to
rewrite links for .jpg etc.

if (!in_array($this->content_type,
array('text/html', 'application/xml+xhtml',
'application/xhtml+xml', 'text/css')) &&
(!$this->content_length || (int)$this->content_length
<= $this->config['max_file_size']))
{
// Impose no time limit since it might
be a large file that would take a long while to download.
+ error_log("sending this page without rewriting
links: " . $this->url . " the content type was " .
$this->content_type . " and the content_length was " .
$this->content_length, 0);
@set_time_limit(0);
$this->send_response_headers();
fpassthru($this->socket);
fclose($this->socket);
exit();
}
+ error_log("we are going to rewrite links for " .
$this->url . " the content type was " .
$this->content_type . " and the content_length was " .
$this->content_length,0);

In my case phperror.log gives me
24-Mar-2006 07:47:34] we are going to rewrite links for
http://www.google.es/ the content type was text/html
and the content_length was
[24-Mar-2006 07:47:35] we are going to rewrite links
for http://www.google.es/images/hp1.gif the content
type was image/gif and the content_length was 2953
[24-Mar-2006 07:47:35] we are going to rewrite links
for http://www.google.es/images/hp3.gif the content
type was image/gif and the content_length was 1410
[24-Mar-2006 07:47:35] we are going to rewrite links
for http://www.google.es/images/hp2.gif the content
type was image/gif and the content_length was 2702
[24-Mar-2006 07:47:35] we are going to rewrite links
for http://www.google.es/images/hp0.gif the content
type was image/gif and the content_length was 4277

The problem is that if the content_type is for example
image/gif and the content_length is greater than the
max_file_size (which is true because max_file_size is
-1 ) the condition in the if evaluates to false and it
tries to rewrite links for audio/mpeg content type. I
think that the conditions should be rewritten so it
does the passthrough always when the content-type is
not in the list OR when the content_length is greater
than max_file_size AND max_file_size is not -1.

Discussion