newlines, backslashes, and quotes in lux.toml generate invalid rockspecs
This lux.toml:
```toml
package = "my-lua-project"
lua = ">=5.2"
[source]
url = 'https://example.com'
[description]
summary = "A sample project."
detailed = '''
first line
second line
'''
maintainer = "myself"
labels = [ "learning" ]
license = "MPL-2.0"
[build]
type = "builtin"
```
Generates this rockspec:
```lua
rockspec_format = "3.0"
package = "my-lua-project"
version = "1.3.7-1"
description = {
summary = "A sample project.",
detailed = "first line
second line
",
license = "MPL-2.0",
maintainer = "myself",
labels = {
"learning",
},
}
dependencies = {
"lua>=5.2",
}
source = {
url = "https://example.com",
}
build = {
type = "builtin",
}
```
Which is invalid. Lua short literal strings are not allowed to contain unescaped line breaks. I've noticed the same thing happens with other characters, so a toml `"foo\\bar"` becomes a Lua `"foo\bar"`, which escapes to a backspace character, and a toml `'foo"bar'` becomes a Lua `"foo"bar"`, which is also invalid.
This will need either to escape special characters or use long literal strings (with a leading newline, otherwise leading newlines in the toml data will end up being swallowed), scanning the string contents ahead of time to determine how many equal signs the long string delimiters need.
0 条评论