in reply to Re: Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts
in thread LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts

As you state an escapeHTML routine is provided by CGI.pm. For the purpose which is intended (ie display plain text in a browser window in the original form) CGI.pm's routine is inadequate.

I make this red flag to bull statement because it does not actually escape text in such a way as to render text with multiple spaces or newlines in a form that imitates the original text. Any sequences of spaces will render as a single space if you use $q->escapeHTML(). The snippet presented does the required &nbsp; subs. It offers the opportunity to convert \n to its HTML equivalent of <BR> which is potentially required. It also adds Perl Monks posting comptibility by escaping the [ and ] which thus far seems to have strangely been overlooked in CGI.pm :-)

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

  • Comment on Re: Re: Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts

Replies are listed 'Best First'.
Re: Re: Re: Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts
by merlyn (Sage) on Sep 24, 2001 at 20:17 UTC
    Then wrap that result in a <pre>...</pre> block. That'd be more appropriate anyway, since the params are likely to be "characters of interest" rather than "text".

    And by the time you've done all that, you're back to realizing that you really didn't want an HTML result in the first place, and you're back to my program which is tons simpler.

    -- Randal L. Schwartz, Perl hacker

      The Answer is 42

      But can even remeber what the original question was?