[plt-scheme] Raw HTML in web server output

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Mar 21 10:33:15 EST 2006

When you make a full response [1], you give the web server a [byte] string
rather than an Xexpr. A substring of this string could be a user provided

If you want to write your application with Xexprs and contain the user's
string in it, then make a new data structure and catch the error xml->string
throws, kind of like this:

(define-struct dave-gurnell-strings (the-user-string))

(with-handlers ([exn:invalid-xexpr?
                      (lambda (exn)
                        (if (dave-gurnell-strings? (exn:invalid-xexpr-code
(exn:invalid-xexpr-code exn))
                            (raise exn)))])
 (xml->string the-xexpr+dgstrings))



On 3/21/06, Dave Gurnell <d.j.gurnell at gmail.com> wrote:
> Dear Schemers,
> I'm trying to write a simple (!!) CMS-style page editor using web-
> server. I have a web form containing a textarea into which the user
> types some HTML. I want to take said HTML, store it in a database,
> and then write it out as part of a web page later on.
> I am using the htmlprag package for the convenience of its (write-
> shtml-as-html ...) procedure. I originally thought said procedure
> might allow me to output raw, unadulterated HTML as a string. This is
> not the case, however.
> I suppose I *could* use htmlprag to parse the user's input into
> XSHTML before it is stored in the database. However, I don't like the
> idea of a user typing something in, saving their page, and then
> coming back to edit it again and finding it changed because htmlprag
> has "corrected" mistakes in the structure. I would prefer the user to
> make mistakes and leave them in the page.
> Does anyone have any suggestions or recommendations?
> Many thanks,
> -- Dave
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Jay McCarthy <jay at cs.brown.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20060321/471b71a7/attachment.html>

Posted on the users mailing list.