------------------------------------------------
On Tue, 22 Jul 2003 16:29:08 -0500, "Josh Corbalis" <[EMAIL PROTECTED]> wrote:

> > I'm writing a webmin module and I'm trying to add a search function 
> > in right now but after I search for it and try to display the output 
> > it has a problem with the way the output is formatted.
> > 
> > print "searchtest<gimp><10>"; will print searchtest<10>
> > print "searchtest< gimp><10>"; will print searchtest< gimp><10>
> > 
> > I don't understand why it will not print any of what is inside the 
> > <> if what is right next to the < is a letter. Numbers and spaces 
> > will print everything on the line but a letter discards everything 
> > in the brackets. I've tried to escape the special meaning of the <> 
> > characters when used with a word but it didn't work. Does anybody 
> > out there have any insight into this problem?
> 
> OK I have some more information about the initial problem as described above.
> The problem isn't really with perl at all but with HTML as this is printing to
> a web page. HTML is taking the <gimp> to be a command for it to execute
> instead of plain text in a string. Should I design a regexp to replace all <
> and > with something else? If so how would I replace something using a regexp?
> I've never used regexps before so some help on this would be great. 
> 

The client (browser) is assuming <gimp> is a tag which was my initial thought, because 
tags can't start with digits your numerical content was working ok.  Yes you can 
replace the < and > with the special HTML replacement characters, &gt; and &lt; and 
one easy method to do this is with a regexp. There are also modules that provide this 
type of functionality, in particular if you are already using the CGI module you 
should have a look at the "escapeHTML" function.  

The following substituitions are possibly an oversimplified way of handling this.

$string =~ s/>/&gt;/g;
$string =~ s/</&lt;/g;

The using a module is still the better approach from a completeness standpoint.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to