-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Special characters shouldn't force double quoting for multi-line strings #246
Special characters shouldn't force double quoting for multi-line strings #246
Conversation
the logic added in c427465 for FasterXML#116 to force double-quoting of strings should only apply to single-line strings. the quoting of multi-line strings look naff, and because they take literal mode, the characters aren't special and the quotes are not necessary.
BTW ideally the characters |
Apologies for slow follow-up here. Yes, I think you are right. On bracket/curly-braces case... I suspect one should only have to worry about opening ones, too? Since it's only pairs that matter, and so if there's no Now, it is possible to distinguish key handling (it's separate method already); and we know from context Array/Object difference as well (so could/should be moved to separate method too?). With that I assume that linefeeds should still force quoting of keys for sure. Anyway. I hope to get back to this one soon and hope we can figure out improvements. Quoting/escaping has proven to be a rather problematic thing.... |
Patch itself is simple: but it would probable make sense to add this to handling of Specifically I see that no info is passed on context (Array vs Object vs Root value (not sure if we have root values in YAML but theoretically)). Passing |
Sigh. Quoting/style checking in 2.12.x is a royal mess. I think this specific change makes sense, and I think I'll actually backport it in 2.12.3. But for 2.13 (and esp. 3.0) this really should be rethought. I also realize that check for key quoting is not considering "funny characters" at all, which is probably not correct... although not sure what SnakeYAML at low level will do. |
As per above comment, will manually merge suggested fix for 2.12. Also filed #252 to improve |
As per above noted, merged manually in 2.12 branch, for inclusion 2.12.3. Thanks! |
I agree with all your points -- esp that keys do still need quoted and that makes life more painful. Thanks for fixing this! |
@ahgittin Thank you for the fix! I will be releasing 2.12.3 patch today. |
the logic added in c427465 for #116 to force double-quoting of strings should only apply to single-line strings. the quoting of multi-line strings look naff, and because they take literal mode, the characters aren't special and the quotes are not necessary.