in reply to br tag in CGI.pm V2.91

Strange. I have CGI.pm v2.752, and by default, it produces XHTML complient <BR /> tags, and states in the pod that this is so unless the -no_xhtml option is used?

-no_xhtml By default, CGI.pm versions 2.69 and higher emit XHTML (http://www.w3. +org/TR/xhtml1/).

A quick test shows this to be the case

C:\test>perl -mCGI -le"$q=new CGI; print $CGI::VERSION; print $q->br;" 2.752 <br /> C:\test>

Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

Replies are listed 'Best First'.
Re: Re: br tag in CGI.pm V2.91
by cLive ;-) (Prior) on Apr 09, 2003 at 21:54 UTC
    I just ran this:
    #!/usr/bin/perl use strict; use CGI; my $q = CGI->new(); print "$CGI::VERSION\n"; print $q->br."\n"; # and it output this: 2.91 <br></br>

    Very weird.

    cLive ;-)

      I just pulled 2.91 and I get the same results as you.

      C:\test>perl -mCGI -le"$q=new CGI; print $CGI::VERSION; $CGI::XHTML=1; + print $q->br;" 2.91 <br></br>

      I even tried explicitly setting $CGI::XHTML = 1; directly--even though it appears to be set to this at line 45 of CGI.pm, and the only place where I can see that it gets modified is at line 718 as a result of the -no_xhtml option. The code generating the BR markup

      1948 $break = $XHTML ? "<br />" : "<br>"; 2116 $break = $XHTML ? "<br />" : "<br>";

      looks like it ought to do the right thing.

      Upshot: I guess it's time to send Lincoln Stein a bug report. You could try for a patch as well, but I'm scuppered if I can see where to patch:)


      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.

        Update: this is actually redundant This Node has a better explanation...

        If it were only that simple :) If you'd looked above these lines, you would have seen that they were within the 'checkbox_group' and 'radio_group' subs (although I think your line number is off in the second case). You need to do a little less casual grepping :)

        After a little play, I think I've narrowed it down to (and sent a note to Lincoln explaining my thoughts) this sub:

        sub _make_tag_func { my ($self,$tagname) = @_; my $func = qq( sub $tagname { shift if \$_[0] && (ref(\$_[0]) && (substr(ref(\$_[0]),0,3) eq 'CGI' || UNIVERSAL::isa(\$_[0],'CGI'))); my(\$attr) = ''; if (ref(\$_[0]) && ref(\$_[0]) eq 'HASH') { my(\@attr) = make_attributes(shift()||undef,1); \$attr = " \@attr" if \@attr; } ); if ($tagname=~/start_(\w+)/i) { $func .= qq! return "<\L$1\E\$attr>";} !; } elsif ($tagname=~/end_(\w+)/i) { $func .= qq! return "<\L/$1\E>"; } !; } else { $func .= qq# return \$XHTML ? "\L<$tagname\E\$attr />" : "\L<$tagname\E\$at +tr>" unless \@_; my(\$tag,\$untag) = ("\L<$tagname\E\$attr>","\L</$tagname>\E") +; my \@result = map { "\$tag\$_\$untag" } (ref(\$_[0]) eq 'ARRAY') ? \@{\$_[0]} : +"\@_"; return "\@result"; }#; } return $func; }
        My guess is that \@_ is always true at the moment, so it never tries to create the XHTML non-container element (it's a little easier to see if you dump the output of the compiled br sub).

        cLive ;-)

Re: br tag in CGI.pm V2.91
by jonadab (Parson) on Apr 10, 2003 at 17:20 UTC
    it produces XHTML complient <BR /> tags

    Huh? Since when is <BR /> XHTML compliant? I'm pretty sure if you stick that in an XHTML document it will not validate.


    for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc' .'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$ p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}