fix(quick-261114-p5m): read tags across raw-text and comment ends in the mail URL check
- unsafeMarkupAt runs the existing HTML reading, then a tag reading in which attribute quoting alone decides where a tag ends (NextIsNotRawText after raw-text start tags, comment openers blanked) - both readings share unsafeAttrs; existing refusals keep their message and snippet - svg/style end tag inside a quoted attribute is refused at check, save and send; README and docs/services/mail.md describe the second reading
This commit is contained in:
@@ -155,7 +155,7 @@ fmt.Println(err != nil, len(driver.Messages()))
|
||||
|
||||
postcard does not pick a locale: the caller passes the full name. A per-language version of a template is a file named after the template, a dash and the locale (`welcome-en.htm`, sent as `acme.blog::mail.welcome-en`). A name with its own file always renders that file. A name the catalog does not hold, of the form `<template>-<locale>` where `<template>` is registered and `<locale>` is a locale tag (two letters, optionally followed by `-` or `_` and a 2 to 8 character subtag, such as `de` or `pt-BR`), sends the default-locale version: the locale's own version when an administrator customized it, else the customized template, else the template's file. Any other unknown name fails with `postcard: unknown template <name>`. So a plugin can pass `<template>-<locale>` for every locale it serves, and a locale without a file still sends mail, in the default language until someone writes that locale's version in the admin.
|
||||
|
||||
Before a driver sees a message, postcard refuses a subject or address with a line break, parses every address with `net/mail`, and rejects rendered HTML that contains script, iframe, object or embed tags, inline event handlers, or `javascript:`, `vbscript:` or `data:` URLs. URLs are looked for where a mail client reads one: URL-bearing attributes such as `href` and `src`, `style` attributes, style elements, comments and `meta` content, after character references are decoded and whitespace removed, so `href="javascript:..."` and `values="java	script:..."` are refused. Markup inside `noscript`, `title`, `textarea`, `style`, `xmp` and similar elements, and inside comments, is checked as well, since a mail client may read it as markup. Text is neither markup nor a URL: a body, a variable or a site name such as `metadata:`, `Big Data: Summit` or `buy one = get one free` is sent; only attributes count as event handlers. Variables are escaped by Go's `html/template`.
|
||||
Before a driver sees a message, postcard refuses a subject or address with a line break, parses every address with `net/mail`, and rejects rendered HTML that contains script, iframe, object or embed tags, inline event handlers, or `javascript:`, `vbscript:` or `data:` URLs. URLs are looked for where a mail client reads one: URL-bearing attributes such as `href` and `src`, `style` attributes, style elements, comments and `meta` content, after character references are decoded and whitespace removed, so `href="javascript:..."` and `values="java	script:..."` are refused. Markup inside `noscript`, `title`, `textarea`, `style`, `xmp` and similar elements, and inside comments, is checked as well, since a mail client may read it as markup. Every tag is also read with attribute quoting alone deciding where it ends, so an end tag or `-->` inside a quoted attribute, as in `<a title="</style>" href="javascript:...">`, does not hide the rest of the tag. Text is neither markup nor a URL: a body, a variable or a site name such as `metadata:`, `Big Data: Summit` or `buy one = get one free` is sent; only attributes count as event handlers. Variables are escaped by Go's `html/template`.
|
||||
|
||||
`postcard.Mailer.Send` delivers before it returns. To keep a request fast, send from a queued job, and send after the write that triggered the mail has committed; see [Queued jobs](jobs.md) and [Transactions](../database/transactions.md).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user