Open Schwusch opened 2 years ago
// exampleKey: ${file(..\/..\/bar.yml)}
Are you sure it's not double quoting it, as:
// exampleKey: "${file(..\/..\/bar.yml)}"
On topic, I'm guessing we could make the strings prettier. Contributions are welcome, but I think it would be best to have:
Are you sure it's not double quoting it, as: // exampleKey: "${file(..\/..\/bar.yml)}"
Oh yeah, that's right. When skipping the {
and }
characters, everything worked as expected during experimentation, with no double quotes or escaping:
doc.update(['exampleKey'], '\$file(../../foo.yml)');
print(doc);
// exampleKey: $file(../../foo.yml)
So curly braces makes this function return true: https://github.com/dart-lang/yaml_edit/blob/4fadb43801b07f90b3f0c6065dbce4efc6d8d55e/lib/src/utils.dart#L15 and then that triggers escaping all code units in this map: https://github.com/dart-lang/yaml_edit/blob/4fadb43801b07f90b3f0c6065dbce4efc6d8d55e/lib/src/strings.dart#L286 But the forward slashes, in itself, does not trigger any character escaping.
I can make a PR if there is a consensus on the solution. Personally, I'd like to pass a parameter to skip all checks for dangerous strings and skip all character replacing somehow.
When updating a string value with forward slashes, the resulting string escapes the forward slashes unnecessarily:
My current workaround is to modify the resulting string:
It would be nice to customize that behaviour.