Re: Stripping white space from HTML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Grant wrote:
>> As I understand it, the reason why you wish the whitespace to be reduced
>> is so you look at the source within your browser, and that you plan to
>> use mod_deflate later ro reduce bandwidth (which is surely not too much
>> of a problem - it's probably equivalent to resampling a few of your
>> images by 5% here and there, or optimising your caching!), but you can't
>> reduce the whitespace inside your application logic (which is where the
>> problem should be fixed) because you don't have control over the code.
>>
>> You have 3 (1,2,4) really good (performance neutral) options not
>> mentioned so far,
>> 1) use a whitespace stripping http proxy you run on your LAN
>> 2) use mod security, removewhitespace in response body
>> 3) use a rewrite rule to a reg exp based whitespace server-side script
>> which serves each page of your application.
>> 4) similar to (3) use an autoprepend rule to serve your white space
>> laden pages through a reg exp based whitespace stripping script.
>>
>> I would probably go for 1,3 or 4, because they are so easy.
>>
>> (2) carries a performance hit, but use of mod security is highly
>> regarded and I would say is an esssential part of protecting an
>> application such as yours - one for which you do not own and cannot
>> change the code.
>
> Thanks Matt.  3 and 4 sound interesting.  How could I configure
> something like that considering my <Location /> block:
>
> <Location />
>       SetHandler perl-script
>       PerlResponseHandler Interchange::Link
>       PerlOptions +GlobalRequest
>       PerlSetVar InterchangeServer /path/to/socket
> </Location>
>
> mod_security also sounds interesting.  It's pretty tricky to set up
> though?
>
> - Grant
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
>
It's those gremlins again, I just checked my post only to find weird
extra pipe symbols in there "|" the php should be

<?php

//script that was requested is $_SERVER{REQUEST_URI}
#ob_start("ob_gzhandler");
ob_start("remove_whitespace");
header( "Content-type: text/html; charset: UTF-8" );
header( "Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT" );

function remove_whitespace($buffer) {
   $buffer = str_replace( array("\r\n", "\r", "\n", "\t", '  ', '    ','    '), '', $buffer );
return $buffer;
}

//might have to append $_SERVER['QUERY_STRING};
require_once( $_SERVER{REQUEST_URI} );
exit;
?>

I should add that you dont really need to pass a long the value of the
original request in the rewrite as php should be able to pick this up
anyway, the query string is possibly all you need to pass along.
It should be noted that I am not using a reg exp here but the faster
str_replace function with an array of likely suspects all of which are
replaced with the empty string ''
Sorry for any confusion resulting from the corrupt post!

-- 
Matthew Farey



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux