question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dumping add quote to string even it is not necessary

See original GitHub issue

As title.

Test Code

const jsYaml = require("js-yaml");
const fs = require("fs");
const yamlStr = jsYaml.dump({ url: "https://github.com/nodeca/js-yaml" });
fs.writeFileSync("foo.yml", yamlStr, { encoding: "utf8" });

Expected Result

url: https://github.com/nodeca/js-yaml

Actual Result

url: 'https://github.com/nodeca/js-yaml'

Problem

https://github.com/nodeca/js-yaml/blob/b6d260927b875404eac8b5e610f41d2f8fbe2425/lib/js-yaml/dumper.js#L294

https://github.com/nodeca/js-yaml/blob/b6d260927b875404eac8b5e610f41d2f8fbe2425/lib/js-yaml/dumper.js#L192-L205

All of these characters ( except0xFEFF ) are safe inside string. Only colon cannot be followed by space or placed at the end of line.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rlidwkacommented, Dec 10, 2020

Fixed in https://github.com/nodeca/js-yaml/commit/db3f52985ba6f3076e6fb4318ca0c5c3c578ccba (in dev branch currently, to be released later).

1reaction
zeropccommented, Jul 2, 2020

Having a same problem here. Since only colon and hash characters are limited in flow scalars, is a PR still welcome by now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get raid of double quotes when dumping a string that ...
if a string to be dumped into a scalar has no special characters, but starts with a double quote, the whole scalar can...
Read more >
Strings in YAML - To Quote or not to Quote | tinita [blogs.perl.org]
Another use case for quotes is when you have a string that would be resolved as a special type. This highly depends on...
Read more >
Using quotation marks with strings in the AWS CLI
Using quotation marks around strings that contain white spaces. Parameter names and their values are separated by spaces on the command line.
Read more >
Documentation: 15: pg_dump - PostgreSQL
Description. pg_dump is a utility for backing up a PostgreSQL database. It makes consistent backups even if the database is being used concurrently....
Read more >
mariadb-dump/mysqldump
It can be used to dump a database or a collection of databases for backup or transfer to another database server (not necessarily...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found