ktoml icon indicating copy to clipboard operation
ktoml copied to clipboard

`@TomlMultiline` does not properly escape backslashes during serialization

Open inponomarev opened this issue 5 months ago • 0 comments

Given:

@Serializable
data class Reproducer(
    @TomlMultiline
    val foo: String
)

val obj = Reproducer("\\\\, \\\"")
val str = Toml.encodeToString(obj)
println(str)
Expectation Reality
foo = """
\\\\, \\"
"""

                                                              



foo = """
\\, \"
"""

                                                              

Then, after deserialization,

println(Toml.decodeFromString<Reproducer>(str).foo)

backslashes get "unescaped" and the foo property of the deserialized object is not equal to the original value:

Expectation Reality
\\, \"

                                                              

\, "

                                                              

inponomarev avatar May 28 '25 18:05 inponomarev