File tree 4 files changed +31
-3
lines changed
main/java/com/fasterxml/jackson/dataformat/yaml/util
test/java/com/fasterxml/jackson/dataformat/yaml/deser
4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -194,3 +194,6 @@ Falk Hanisch (mrpiggi@github)
194
194
for the same POJO
195
195
(2.13.1 )
196
196
197
+ Esteban Ginez (eginez@github)
198
+ #306 : (yaml) Error when generating/serializing keys with multilines and colon
199
+ (2.13.2 )
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ No changes since 2.13
22
22
23
23
#303 : (yaml) Update to SnakeYAML 1.30
24
24
(suggested by PJ Fanning)
25
+ #306 : (yaml) Error when generating/serializing keys with multilines and colon
26
+ (reported by Esteban G)
25
27
26
28
2.13.1 (19 -Dec-2021 )
27
29
Original file line number Diff line number Diff line change @@ -163,7 +163,27 @@ protected boolean valueHasQuotableChar(String inputStr)
163
163
}
164
164
return false ;
165
165
}
166
-
166
+
167
+ /**
168
+ * Looks like we may get names with "funny characters" so.
169
+ *
170
+ * @since 2.13.2
171
+ */
172
+ protected boolean nameHasQuotableChar (String inputStr )
173
+ {
174
+ // 31-Jan-2022, tatu: As per [dataformats-text#306] linefeed is
175
+ // problematic. I'm sure there are likely other cases, but let's
176
+ // start with the obvious ones, control characters
177
+ final int end = inputStr .length ();
178
+ for (int i = 0 ; i < end ; ++i ) {
179
+ int ch = inputStr .charAt (i );
180
+ if (ch < 0x0020 ) {
181
+ return true ;
182
+ }
183
+ }
184
+ return false ;
185
+ }
186
+
167
187
/**
168
188
* Default {@link StringQuotingChecker} implementation used unless
169
189
* custom implementation registered.
@@ -189,7 +209,10 @@ public Default() { }
189
209
@ Override
190
210
public boolean needToQuoteName (String name )
191
211
{
192
- return isReservedKeyword (name ) || looksLikeYAMLNumber (name );
212
+ return isReservedKeyword (name ) || looksLikeYAMLNumber (name )
213
+ // 31-Jan-2022, tatu: as per [dataformats-text#306] may also
214
+ // have other characters requiring quoting...
215
+ || nameHasQuotableChar (name );
193
216
}
194
217
195
218
/**
Original file line number Diff line number Diff line change 1
- package com .fasterxml .jackson .dataformat .yaml .failing ;
1
+ package com .fasterxml .jackson .dataformat .yaml .deser ;
2
2
3
3
import java .util .Collections ;
4
4
import java .util .Map ;
You can’t perform that action at this time.
0 commit comments