library for doing html escaping...

Discussion in 'Ruby' started by Sean T Allen, Apr 29, 2005.

  1. Sean T Allen

    Sean T Allen Guest

    --------------090403080404050404020301
    Content-Type: text/plain; charset=ISO-8859-1; format=flowed
    Content-Transfer-Encoding: 7bit

    ruby forge drives me crazy trying to find things...

    need a library that provides simple functionality of take a string and
    doing html escaping

    " to "
    & to &

    etc.

    suggestions....

    --------------090403080404050404020301
    Content-Type: text/x-vcard; charset=utf-8;
    name="sean.vcf"
    Content-Transfer-Encoding: 7bit
    Content-Disposition: attachment;
    filename="sean.vcf"

    begin:vcard
    fn:Sean T. Allen
    n:Allen;Sean T.
    org:Ardis Marketing Group
    adr;dom:;;;New York;NY
    email;internet:
    title:Tech Guru
    x-mozilla-html:FALSE
    url:http://ardismg.com/
    version:2.1
    end:vcard


    --------------090403080404050404020301--
    Sean T Allen, Apr 29, 2005
    #1
    1. Advertising

  2. Sean T Allen

    Phlip Guest

    Sean T Allen wrote:

    > ruby forge drives me crazy trying to find things...


    Sometimes what you seek was obvious to everyone else, so they didn't
    excessively document it. Sorry.

    > need a library that provides simple functionality of take a string and
    > doing html escaping
    >
    > " to "
    > & to &


    require 'cgi'
    ....

    def test_escapeHTML()
    scream = CGI::escapeHTML(">scream<")
    assert_equal(scream, '&gt;scream&lt;')
    end

    --
    Phlip
    http://www.c2.com/cgi/wiki?ZeekLand
    Phlip, Apr 29, 2005
    #2
    1. Advertising

  3. Sean T Allen

    Guest

    On Sat, 30 Apr 2005, Sean T Allen wrote:

    > --------------090403080404050404020301
    > Content-Type: text/plain; charset=ISO-8859-1; format=flowed
    > Content-Transfer-Encoding: 7bit
    >
    > ruby forge drives me crazy trying to find things...
    >
    > need a library that provides simple functionality of take a string and
    > doing html escaping
    >
    > " to &quot;
    > & to &amp;
    >
    > etc.
    >
    > suggestions....
    >


    it's builtin to ruby:

    harp:~ > irb -r cgi
    irb(main):001:0> CGI::escapeHTML %Q( " )
    => " &quot; "
    irb(main):002:0> CGI::escapeHTML %Q( & )
    => " &amp; "
    irb(main):003:0> CGI::escapeHTML %Q( < )
    => " &lt; "
    irb(main):004:0> CGI::escapeHTML %Q( > )
    => " &gt; "

    cheers.
    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | renunciation is not getting rid of the things of this world, but accepting
    | that they pass away. --aitken roshi
    ===============================================================================
    , Apr 29, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Nentwig

    JSP2/EL: escaping HTML

    Timo Nentwig, Apr 29, 2004, in forum: Java
    Replies:
    0
    Views:
    345
    Timo Nentwig
    Apr 29, 2004
  2. Timo Nentwig

    EL: escaping HTML

    Timo Nentwig, May 8, 2004, in forum: Java
    Replies:
    4
    Views:
    7,780
    Timo Nentwig
    May 10, 2004
  3. Csaba2000

    Reverse escaping in HTML

    Csaba2000, Jan 17, 2004, in forum: HTML
    Replies:
    1
    Views:
    842
    Brian
    Jan 17, 2004
  4. Jim Bancroft

    help w/HTML escaping in XML tags?

    Jim Bancroft, Mar 2, 2005, in forum: XML
    Replies:
    5
    Views:
    1,118
    Peter Flynn
    Mar 6, 2005
  5. Replies:
    3
    Views:
    157
Loading...

Share This Page