[Html-widget] HTML::Element bug (was Re: Bug in HTML::Widget::Constraint::In)
A. Pagaltzis
pagaltzis at gmx.de
Wed Oct 18 16:18:44 CEST 2006
* Bernhard Graf <html-widget at augensalat.de> [2006-10-18 14:45]:
> sub _xml_escape { # DESTRUCTIVE (a.k.a. "in-place")
> local $_;
You don’t need to localise `$_` there as `foreach` will only
alias it anyway. (In fact `for($var)` should be preferred over
`local $_ = $var` for reasons having to do with not breaking any
magic associated with the previous `$_` or `*_`.)
> foreach (@_) {
> s/&/&/go;
> s/</</go;
> s/>/>/go;
> s/"/"/go;
The `/o` switches do nothing here. Also, generally, don’t use
`/o`.
You also need to escape single quotes in order for this to be
complete. Since `'` is only defined for XML and derivatives
but not for HTML, it’s safer to use `'`. It’s shorter, too.
What I end up doing is this:
s[ ([&"']) ]{ '&#' . ord( $1 ) . ';' }xge;
s[ < ][<]xg;
s[ > ][>]xg;
> }
> return;
> }
Regards,
--
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;
More information about the Html-widget
mailing list