Skip to content

Line ending backslash in """ causes later line breaks to also be removed #372

Closed

Description

@JoelColledge

Hi, I'm having trouble with breaking long lines in """ delimited strings using a backslash. This is called a "line ending backslash" in the toml spec.

Reproducer:

package main

import (
	"fmt"
	"os"

	"github.com/BurntSushi/toml"
)

const in = `f = """
a\
b
c
"""`

func main() {
	var out map[string]string
	if _, err := toml.Decode(in, &out); err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(1)
	}

	fmt.Println(out["f"])
}

Expected output, which is generated with BurntSushi/toml v0.3.1:

ab
c

Output with BurntSushi/toml v1.2.1:

abc

Any chance of fixing this? Thanks!

Activity

  1. arp242 commented on Nov 8, 2022

    @arp242
    Collaborator

    This probably broke quite a few releases ago, as this hasn't been touched since last year; I'm guessing with 35432de.

    I should probably rewrite that entire logic; I'm having trouble following it now.

  2. added 3 commits that reference this issue on May 23, 2023
    f9b655e
    fb9756b
    712b1a5
  3. cespare commented on May 23, 2023

    @cespare
    Collaborator

    Yikes. I sent #391.

    @arp242 would you mind giving that a review and then cutting a 1.2.2 release? Or I'm happy to do it, though I figure you would have a better idea of what all to mention in the release notes.

  4. added a commit that references this issue on May 23, 2023
    53a200c
  5. arp242 commented on May 23, 2023

    @arp242
    Collaborator

    would you mind giving that a review and then cutting a 1.2.2 release? Or I'm happy to do it, though I figure you would have a better idea of what all to mention in the release notes.

    Let me take a look at #371 before the release; then every (known) bug should be fixed.

  6. added a commit that references this issue on May 23, 2023
    a2cbdda
  7. cespare commented on May 23, 2023

    @cespare
    Collaborator

    @arp242 I took at stab at that in #392 to try to speed things along.

    However, I would say that this is a much more serious issue since (I'd guess) orders of magnitude more code depends on decoding than encoding. This bug caused a configuration issue at my work which is how it came to my attention.

  8. arp242 commented on May 23, 2023

    @arp242
    Collaborator

    I would say that this is a much more serious issue since (I'd guess) orders of magnitude more code depends on decoding than encoding.

    I agree; I would (should) have fixed it much earlier; I just haven't been able to spend as much time on things in the last few months as I'd like due to some personal issues; I've been picking up things again since last week, but there's a bit of a backlog (so many emails...). I actually did create a quick fix yesterday, but your PR pre-empted that (and it's nicer anyway).

    However, it seems to have been broken since June 2021, so it's less often used than I would expect, and in that context a few more days probably won't matter too much, I think? It avoids having to push out a new bugfix release just for that.

  9. cespare commented on May 23, 2023

    @cespare
    Collaborator

    However, it seems to have been broken since June 2021, so it's less often used than I would expect,

    One thing that makes that a bit tricky to evaluate is that people might not be pulling in the latest version of this package very quickly in well-established code bases with a lot of TOML given how MVS works. At my work we only pulled in this bug about five months ago.

    and in that context a few more days probably won't matter too much, I think? It avoids having to push out a new bugfix release just for that.

    Sure, a few days is fine by me. And as I said I'm also happy to run the release if that would help.

  10. arp242 commented on May 30, 2023

    @arp242
    Collaborator

    I tagged v1.3.0.

  11. cespare commented on May 30, 2023

    @cespare
    Collaborator

    @arp242 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址