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

YAML export escapes quotes #56

Closed
amesgen opened this issue Apr 23, 2020 · 3 comments · Fixed by #57
Closed

YAML export escapes quotes #56

amesgen opened this issue Apr 23, 2020 · 3 comments · Fixed by #57

Comments

@amesgen
Copy link
Contributor

amesgen commented Apr 23, 2020

Another one:

@ YamlConverter.toYamlString(parse(""" { a = "\"\n" } """)) 
res19: String = """a: |
  \"
"""

EDIT the newline is irrelevant

@ YamlConverter.toYamlString(parse(""" { a = "\"" } """)) 
res5: String = """a: \"
"""
@amesgen
Copy link
Contributor Author

amesgen commented Apr 23, 2020

A very unsatisfying fix:

diff --git a/modules/yaml/src/main/java/org/dhallj/yaml/YamlHandler.java b/modules/yaml/src/main/java/org/dhallj/yaml/YamlHandler.java
index f3f6efa..09dc5d8 100644
--- a/modules/yaml/src/main/java/org/dhallj/yaml/YamlHandler.java
+++ b/modules/yaml/src/main/java/org/dhallj/yaml/YamlHandler.java
@@ -46,7 +46,7 @@ public class YamlHandler implements JsonHandler {
   }
 
   public void onString(String value) {
-    this.addValue(value.replaceAll("\\\\n", "\n"));
+    this.addValue(value.replaceAll("\\\\n", "\n").replaceAll("\\\\\"", "\""));
   }
 
   public void onArrayStart() {

@travisbrown
Copy link
Owner

@amesgen Do you want to PR that fix as a temporary solution? I should have some time to work on #11 this weekend or early next week, and was planning to publish an 0.2.1 with #54 today anyway.

@amesgen
Copy link
Contributor Author

amesgen commented Apr 23, 2020

👍 @ 0.2.1 with this fix.

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

Successfully merging a pull request may close this issue.

2 participants