On Sat, Aug 20, 2022 at 05:05:22PM -0700, Aleix Conchillo Flaqué wrote: > Hi Maxime, > > On Sat, Aug 20, 2022 at 2:48 PM Maxime Devos <maximede...@telenet.be> wrote: > > > > The GuileScript looks nice, for interested readers, see < > https://github.com/aconchillo/guilescript> > > > > On 20-08-2022 21:59, Aleix Conchillo Flaqué wrote: > > > > However, I'm not able to find a way to avoid character encoding/escaping > and the generated code inside <script> will always have "<", etc. And > <script> is a place where encodings can be avoided. This is true for both > Guile and guile-lib's (htmlprag), even though htmlprag's escapes less > characters (e.g. double quotes).
Indeed. <script> is a monster in this endless tragicomedy which is HTML. Here's what the WHATWG has to say [1] on it: "The easiest and safest way to avoid the rather strange restrictions described in this section is to always escape an ASCII case-insensitive match for "<!--" as "\x3C!--", "<script" as "\x3Cscript", and "</script" as "\x3C/script" when these sequences appear in literals in scripts [...], and to avoid writing code that uses such constructs in expressions." So basically, what you have to do to preprocess your script is to find out whether the offending sequences (i.e. "<!--" [I'd have forgotten that one], and "<script" [why?] and finally "</script") with their (javastring-) escaped counterparts whenever they appear in javascript strings... and not use them otherwise. If your language is not javascript... good luck. Cheers [1] https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements -- t
signature.asc
Description: PGP signature