unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: guile-devel@gnu.org
Subject: Re: avoid character encoding/escaping in sxml->xml or htmlprag's sxml->html
Date: Sun, 21 Aug 2022 07:09:55 +0200	[thread overview]
Message-ID: <YwG+I7QC8C7y/+fi@tuxteam.de> (raw)
In-Reply-To: <CA+XASoVEzySx3m15KAoDprEYu36Q0k6Cu=TsZhJM9XVMaBTn2g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1713 bytes --]

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 <maximedevos@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 "&lt;", 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2022-08-21  5:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-20 19:59 avoid character encoding/escaping in sxml->xml or htmlprag's sxml->html Aleix Conchillo Flaqué
2022-08-20 21:48 ` Maxime Devos
2022-08-21  0:05   ` Aleix Conchillo Flaqué
2022-08-21  5:09     ` tomas [this message]
2022-08-21 10:16     ` Maxime Devos
2022-08-21 10:23       ` tomas
2022-08-21 22:34       ` Aleix Conchillo Flaqué

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YwG+I7QC8C7y/+fi@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).