[plt-scheme] Raw HTML in web server output

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Tue Mar 21 12:55:17 EST 2006

Thanks for the advice - it certainly seems like I'm on the right  
track now. I've come across another problem: the xml->string  
procedure throws an exn:fail when it fails instead of an exn:invalid- 
xexpr.

The correct-xexpr? procedure seems to do something similar to what  
you describe but I haven't managed to figure out how from the  
documentation how it works or whether it's relevant.

I'll post again when I make further advances.

Many thanks,

-- Dave

> 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 string.
>
> 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))
>
> (make-response/full
>  ....
> (with-handlers ([exn:invalid-xexpr?
>                       (lambda (exn)
>                         (if (dave-gurnell-strings? (exn:invalid- 
> xexpr-code exn))
>                             (dave-gurnell-strings-the-user-string  
> (exn:invalid-xexpr-code exn))
>                             (raise exn)))])
>  (xml->string the-xexpr+dgstrings))
>  .....)
>
> Jay


Posted on the users mailing list.