[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Binary value in Literal syntax resulting in extra newline character being added. #1292

Open
davidzchen opened this issue Jun 28, 2024 · 2 comments

Comments

@davidzchen
Copy link

The following should have the same value:

binary: !!binary AAAAA
binary: !!binary |
  AAAAA

However, when parsed, the latter value has a '\n' appended to the end of it:

#include <cassert>
#include <cstdlib>
#include <string>

#include "yaml-cpp/yaml.h"

int main(int argc, char** argv) {
  YAML::Node n0 = YAML::Load(R"(
    binary: !!binary AAAAA
  )");
  assert(n0["binary"].as<std::string>() == "AAAAA");

  YAML::Node n1 = YAML::Load(R"(
    binary: !!binary |
      AAAAA
  )");
  assert(n1["binary"].as<std::string>() == "AAAAA\n");

  return EXIT_SUCCESS;
}

@jbeder Is this a bug?

@jbeder
Copy link
Owner
jbeder commented Jun 28, 2024

Not sure. Can you take a look at the Literal spec? It's possible it adds a new line in that example.

@davidzchen
Copy link
Author

Here is the section of the spec regarding Literal Style: https://yaml.org/spec/1.2.2/#812-literal-style

I am not familiar with the syntax and format of the spec, but it does mention "final line breaks and trailing empty lines are chomped."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants