Google Answers Logo
View Question
 
Q: Modification of CGI-Proxy (PERL) ( No Answer,   0 Comments )
Question  
Subject: Modification of CGI-Proxy (PERL)
Category: Computers > Programming
Asked by: pcdivenii-ga
List Price: $50.00
Posted: 21 Jan 2003 15:34 PST
Expires: 29 Jan 2003 09:18 PST
Question ID: 146715
I am using James Marshall's CGI-Proxy
http://www.jmarshall.com/tools/cgiproxy/.

I would like to use the script to specifically replace the following
JavaScript in all HTML pages processed through the CGI-Proxy:

if(parent.frames.length!=0)top.location='whatever.html';

I do not want to disable JavaScript entirely in the post-processed
HTML pages, I just want to get rid of the above JavaScript and
anything that accomplishes its function.

How exactly would I go about adding this filtering element to the
CGI-Proxy script? Where and how can I do this in the script?

I am looking for someone who can simply modify the script for this purpose.

Thank you!

Any questions, please e-mail to: junkmail@patmail.com

-Pat

Request for Question Clarification by studboy-ga on 21 Jan 2003 19:33 PST
Hi, try doing it before, in, or after proxify_html at line 1540:

Try this--

if ( $is_html  && ($body ne '') && !$response_sent ) {

    $body=~ s/if(parent.frames.length!=0)top.location='whatever.html';//g;

    $body= &proxify_html(\$body, 1) ;

    # Change Content-Length header, since we changed the content
    $headers=~ s/^Content-Length:.*\012/
		 'Content-Length: ' . length($body) . "\015\012"/mie ;

Request for Question Clarification by studboy-ga on 21 Jan 2003 19:33 PST
Let me know if it works.  Thanks.
Answer  
There is no answer at this time.

The following answer was rejected by the asker (they received a refund for the question).
Subject: Re: Modification of CGI-Proxy (PERL)
Answered By: studboy-ga on 23 Jan 2003 22:37 PST
 
The line of Javascript can be removed by doing a regular expression
substitution right before the response is sent back to the user--
ie, add the line 

$body=~ s/if(parent.frames.length!=0)top.location='whatever.html';//g;

to line 1540 to make it look like this:

if ( $is_html  && ($body ne '') && !$response_sent ) { 
 
    # remove the line of Javascript
    $body=~ s/if(parent.frames.length!=0)top.location='whatever.html';//g; 
 
    $body= &proxify_html(\$body, 1) ; 
 
    # Change Content-Length header, since we changed the content 
    $headers=~ s/^Content-Length:.*\012/ 
   'Content-Length: ' . length($body) . "\015\012"/mie ;

Request for Answer Clarification by pcdivenii-ga on 23 Jan 2003 23:44 PST
This is just going to remove anything that has that EXACT
characterization, correct?

It will only scan for and remove this VERY same line?:

$body=~ s/if(parent.frames.length!=0)top.location='whatever.html';//g;

In addition, it will only remove it points to "whatever.html" as well?

How can I make this more dynamic?

Request for Answer Clarification by pcdivenii-ga on 23 Jan 2003 23:50 PST
*WHEN it points...

Request for Answer Clarification by pcdivenii-ga on 24 Jan 2003 00:46 PST
The above, using that same exact line did not work either, unfortunately.

Clarification of Answer by studboy-ga on 24 Jan 2003 01:04 PST
Dear pcdivenii-ga 

Yes, in your original question you didn't specify you need a dynamic solution--but
You can make it more dynamic by use of regular expressions--
for example--the following is a lot more dynamic and it will tolerate
white spaces between the words:

$body=~ s/\s*if\s*(parent.frames.length\s*!\s*=\s*0)\s*top.location\s*=\s*'.*';//g;

Please give this one a try.

studboy-ga

If it
Reason this answer was rejected by pcdivenii-ga:
Unfortunately, studboy-ga was unable to fulfill my request. The
answer, and then clarification, did not work at all. It was thoroughly
tested on my own server.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy