diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-25 18:11:54 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-25 18:11:54 -0700 |
| commit | 2089fa738b2299d864b614567e97d2bc57556fb4 (patch) | |
| tree | 6430455e750deabe9fc39cfd69a593d999684f1b /asspb.go | |
| parent | 9bdd477fb41084b47a15f2834b97a899b8b605ca (diff) | |
| download | ccl-2089fa738b2299d864b614567e97d2bc57556fb4.tar.zst | |
Make sure to remove \r\n as well as \n for Windows
Diffstat (limited to 'asspb.go')
| -rw-r--r-- | asspb.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -65,6 +65,8 @@ // // As an extension to the C11 escapes, a backslash immediately before a newline // character (0x0a) will remove the newline character from the resulting string +// (and for you Microsoft Windows users, backslash followed by \r\n is +// also removed) // // 'backslash also can \ // remove newlines' @@ -219,7 +221,7 @@ func (p *parser) parseNum() (any, bool) { return n, true } -var escapesRE = regexp.MustCompile(`(?s)\\(.|[0-7]{3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})`) +var escapesRE = regexp.MustCompile(`(?s)\\(.|\r\n|[0-7]{3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})`) func init() { escapesRE.Longest() @@ -251,7 +253,7 @@ func unescape(idx int, rawStr []byte) ([]byte, error) { return []byte("\t") case `\v`: return []byte("\v") - case "\\\n": + case "\\\n", "\\\r\n": return nil } if bytes.HasPrefix(escape, []byte(`\x`)) || bytes.HasPrefix(escape, []byte(`\u`)) || bytes.HasPrefix(escape, []byte(`\U`)) { |
