[Html-widget] HTML::Element bug (was Re: Bug in HTML::Widget::Constraint::In)
Bernhard Graf
html-widget at augensalat.de
Wed Oct 18 16:31:36 CEST 2006
Argh. Nervous finger...
> * 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 `*_`.)
Interesting.
> > foreach (@_) {
> > s/&/&/go;
> > s/</</go;
> > s/>/>/go;
> > s/"/"/go;
>
> The `/o` switches do nothing here. Also, generally, don’t use
> `/o`.
Aha. Why?
> 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;
And why not
s[ ([&"'<>]) ]{ '&#' . ord( $1 ) . ';' }xge;
then?
--
Bernhard Graf
More information about the Html-widget
mailing list