From: ·············@gustad.com
Subject: AllegroServe html macro question
Date: 
Message-ID: <kjuzmxe9qzd.fsf@shardlow.dolphinics.no>
The documentation(1) for the html macro says:

The values are evaluated and printed with a function that escapes
characters with special meaning in html : <, >, &, ".

But I run into problems when I use &, e.g.
  (html ((:img :src (format nil "someurl/~D" (random 10)))))
   => <img SRC="someurl/2">
  (html ((:img :src (format nil "someurl&~D" (random 10)))))
   =>
   No matching method for the generic-function #<WRITE-SEQUENCE...>,
   when called with arguments ("someurl&7" NIL :START 0 :END 7).

Do I need to escape the & myself? Can't see why this should cause the
stream to be nil.

Petter


1) http://opensource.franz.com/aserve/aserve-dist/doc/htmlgen.html
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

From: Wade Humeniuk
Subject: Re: AllegroServe html macro question
Date: 
Message-ID: <PykXd.9390$i6.3457@edtnps90>
·············@gustad.com wrote:
> The documentation(1) for the html macro says:
> 
> The values are evaluated and printed with a function that escapes
> characters with special meaning in html : <, >, &, ".
> 
> But I run into problems when I use &, e.g.
>   (html ((:img :src (format nil "someurl/~D" (random 10)))))
>    => <img SRC="someurl/2">
>   (html ((:img :src (format nil "someurl&~D" (random 10)))))
>    =>
>    No matching method for the generic-function #<WRITE-SEQUENCE...>,
>    when called with arguments ("someurl&7" NIL :START 0 :END 7).
> 
> Do I need to escape the & myself? Can't see why this should cause the
> stream to be nil.
> 

It seems you have to bind *html-stream* to some existing stream first.
Try:

(let ((*html-stream* *standard-output*))
    (html ((:img :src (format nil "someurl&~D" (random 10))))))

The problem seems to be in net.html.generator::emit-safe . If
there are escaped chars then it calls write-sequence which
fails on a nil stream.

If there are no escaped chars it uses write-string which accepts a
nil stream without bombing.

Wade
From: Petter Gustad
Subject: Re: AllegroServe html macro question
Date: 
Message-ID: <87r7ikd1y4.fsf@parish.home.gustad.com>
Wade Humeniuk <··················@telus.net> writes:

> It seems you have to bind *html-stream* to some existing stream first.
> Try:
> 
> (let ((*html-stream* *standard-output*))
>     (html ((:img :src (format nil "someurl&~D" (random 10))))))
> 
> The problem seems to be in net.html.generator::emit-safe . If
> there are escaped chars then it calls write-sequence which
> fails on a nil stream.

Thanks. AllegroServe should bind *html-stream* so I guess this should
not be a problem at all..

Petter
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?