@@ -415,18 +415,25 @@ private final Object _deserializeAltString(JsonParser p, DeserializationContext
415
415
// [databind#149]: Allow use of 'String' indexes as well -- unless prohibited (as per above)
416
416
char c = name .charAt (0 );
417
417
if (c >= '0' && c <= '9' ) {
418
- try {
419
- int index = Integer .parseInt (name );
420
- if (!ctxt .isEnabled (MapperFeature .ALLOW_COERCION_OF_SCALARS )) {
421
- return ctxt .handleWeirdStringValue (_enumClass (), name ,
418
+ // [databind#4403]: cannot prevent "Stringified" numbers as Enum
419
+ // index yet (might need combination of "Does format have Numbers"
420
+ // (XML does not f.ex) and new `EnumFeature`. But can disallow "001" etc.
421
+ if (c == '0' && name .length () > 1 ) {
422
+ ;
423
+ } else {
424
+ try {
425
+ int index = Integer .parseInt (name );
426
+ if (!ctxt .isEnabled (MapperFeature .ALLOW_COERCION_OF_SCALARS )) {
427
+ return ctxt .handleWeirdStringValue (_enumClass (), name ,
422
428
"value looks like quoted Enum index, but `MapperFeature.ALLOW_COERCION_OF_SCALARS` prevents use"
423
- );
429
+ );
430
+ }
431
+ if (index >= 0 && index < _enumsByIndex .length ) {
432
+ return _enumsByIndex [index ];
433
+ }
434
+ } catch (NumberFormatException e ) {
435
+ // fine, ignore, was not an integer
424
436
}
425
- if (index >= 0 && index < _enumsByIndex .length ) {
426
- return _enumsByIndex [index ];
427
- }
428
- } catch (NumberFormatException e ) {
429
- // fine, ignore, was not an integer
430
437
}
431
438
}
432
439
}
0 commit comments