google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.34k stars 212 forks source link

syntax: strict string escapes #265

Closed alandonovan closed 4 years ago

alandonovan commented 4 years ago

This change causes Starlark, like Go, to reject backslashes that are not part of an escape sequence. Previously they were treated literally, so \ ( would encode a two-character string, and much code relied on this, especially for regular expressions.

This may break some programs, but the fix is simple: double each errant backslashes.

Python does not yet enforce this behavior, but since 3.6 has emitted a deprecation warning for it.

Also, document string escapes.

This is Google issue b/34519173.

Change-Id: I5c9609a4e28d58593e9d6918757bca2cfd838d51

alandonovan commented 4 years ago

@laurentlb