Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Substituting URLs in PerlOutputFilterHandler

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


puneet at cs

Nov 9, 2008, 10:45 PM

Post #1 of 3 (912 views)
Permalink
Substituting URLs in PerlOutputFilterHandler

Hi,

I am trying to write a handler that modifies the content of the page
based on a regex match. essentially im trying to modify <a href="">
tags in the outgoing HTML pages.
Now I am trying to do this using PerlOutputFilterHandler. I have the
following questions:
a) Is this the right filter to use for an application like this?
b) As per my understanding my hander can be invoked multiple times
based on the no. of buckets. Is this correct? If yes, then how should
I handle the situation where a part of the tag like say '<a href'
comes in one bucket and '="">' comes in another.

Thanks for your time.

--
Regards,
Puneet


torsten.foertsch at gmx

Nov 10, 2008, 1:11 AM

Post #2 of 3 (887 views)
Permalink
Re: Substituting URLs in PerlOutputFilterHandler [In reply to]

On Mon 10 Nov 2008, Puneet Lakhina wrote:
> essentially im trying to modify <a href="">
> tags in the outgoing HTML pages.
> Now I am trying to do this using PerlOutputFilterHandler. I have the
> following questions:
> a) Is this the right filter to use for an application like this?

yes

> b) As per my understanding my hander can be invoked multiple times
> based on the no. of buckets. Is this correct?

yes

> If yes, then how should
> I handle the situation where a part of the tag like say '<a href'
> comes in one bucket and '="">' comes in another.

The basic idea is to carry around the tail of the current buffer,
the '<a href', in the filter context. The last handler in this chapter

http://perl.apache.org/docs/2.0/user/handlers/filters.html#Stream_oriented_Output_Filters

shows the technique.

The OutputFilter routine in Apache2::ClickPath (on CPAN) is another
example.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch [at] gmx


adam.prime at utoronto

Nov 10, 2008, 6:05 AM

Post #3 of 3 (892 views)
Permalink
Re: Substituting URLs in PerlOutputFilterHandler [In reply to]

Puneet Lakhina wrote:
> Hi,
>
> I am trying to write a handler that modifies the content of the page
> based on a regex match. essentially im trying to modify <a href="">
> tags in the outgoing HTML pages.
> Now I am trying to do this using PerlOutputFilterHandler. I have the
> following questions:
> a) Is this the right filter to use for an application like this?
> b) As per my understanding my hander can be invoked multiple times
> based on the no. of buckets. Is this correct? If yes, then how should
> I handle the situation where a part of the tag like say '<a href'
> comes in one bucket and '="">' comes in another.

This is exactly the situation that Apache2::Filter::TagAware was built for.

http://search.cpan.org/~aprime/Apache2-Filter-TagAware-0.02/lib/Apache2/Filter/TagAware.pm

Adam

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.