Substituting URLs in PerlOutputFilterHandler

This is a discussion on Substituting URLs in PerlOutputFilterHandler within the Apache forums in Application Servers & Tools category; 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' ...

Go Back   Application Development Forum > Application Servers & Tools > Apache

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 11-10-2008, 01:45 AM
Puneet Lakhina
Guest
 
Default 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

Reply With Quote
  #2  
Old 11-10-2008, 04:11 AM
Torsten Foertsch
Guest
 
Default Re: Substituting URLs in PerlOutputFilterHandler

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...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@gmx.net

Reply With Quote
  #3  
Old 11-10-2008, 09:05 AM
Adam Prime
Guest
 
Default Re: Substituting URLs in PerlOutputFilterHandler

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/Apach...er/TagAware.pm

Adam

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:55 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.