mirror of
https://github.com/tmedwards/tweego.git
synced 2025-07-04 21:50:33 -04:00
[New, Update] Messy commit.
* [Update] Add module paths to watch files. From the old Bitbucket repo, submitted by `MarkSill`. * [Fix] Trim erroneous whitespace surrounding the story title. From the old Bitbucket repo. * [Update, Devel, Docs] Changed import and doc paths to point to the GitHub repo and removed Mercurial references. * [Fix] Leading whitespace on passages is trimmed as intended. * [New, Docs] Added an option to disable passage trimming (`--no-trim`). * [Update] Update IFID commentary and cleanup. * [Update] Switched to another SemVer module due to a few issues with the old one. * [Update] Purged commented legacy & debug code.
This commit is contained in:
parent
57e1aa52ff
commit
1bb4278938
15 changed files with 123 additions and 64 deletions
14
escaping.go
14
escaping.go
|
@ -18,7 +18,7 @@ import (
|
|||
var attrEscaper = strings.NewReplacer(
|
||||
`&`, `&`,
|
||||
`"`, `"`,
|
||||
// FIXME: Keep the following? All markup we generate double quotes attribute
|
||||
// QUESTION: Keep the following? All markup we generate double quotes attribute
|
||||
// values, so escaping single quotes/apostrophes isn't actually necessary.
|
||||
`'`, `'`,
|
||||
)
|
||||
|
@ -30,15 +30,14 @@ func attrEscapeString(s string) string {
|
|||
return attrEscaper.Replace(s)
|
||||
}
|
||||
|
||||
// Escape the minimum characters required for general HTML escaping—i.e. only
|
||||
// Escape the minimum characters required for general HTML escaping—i.e., only
|
||||
// the special characters (`&`, `<`, `>`, `"`, `'`).
|
||||
//
|
||||
// NOTE: The following exists because `html.EscapeString()` converts double
|
||||
// quotes (`"`) to their decimal numeric character reference (`"`) rather
|
||||
// than to their entity (`"`). While the behavior is entirely legal, and
|
||||
// browsers will happily accept the NCRs, a not insignificant amount of JavaScript
|
||||
// code does not expect it and will fail to properly unescape the NCR—expecting
|
||||
// only `"`.
|
||||
// browsers will happily accept the NCRs, a not insignificant amount of code in
|
||||
// the wild only checks for `"` and will fail to properly unescape the NCR.
|
||||
//
|
||||
// The primary special characters (`&`, `<`, `>`, `"`) should always be
|
||||
// converted to their entity forms and never to an NCR form. Saving one byte
|
||||
|
@ -101,11 +100,6 @@ func tweeEscapeBytes(s []byte) []byte {
|
|||
if len(s) == 0 {
|
||||
return []byte(nil)
|
||||
}
|
||||
// e := bytes.Replace(s, []byte("\\"), []byte("\\\\"), -1)
|
||||
// e = bytes.Replace(e, []byte("["), []byte("\\["), -1)
|
||||
// e = bytes.Replace(e, []byte("]"), []byte("\\]"), -1)
|
||||
// e = bytes.Replace(e, []byte("{"), []byte("\\{"), -1)
|
||||
// e = bytes.Replace(e, []byte("}"), []byte("\\}"), -1)
|
||||
|
||||
// NOTE: The slices this will be used with will be short enough that
|
||||
// iterating a slice twice shouldn't be problematic. That said,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue