@@ -107,63 +107,10 @@ public class ParserConfig {
107
107
}
108
108
109
109
INTERNAL_WHITELIST_HASHCODES = new long [] {
110
- 0x82E8E13016B73F9EL ,
111
- 0x863D2DD1E82B9ED9L ,
112
- 0x8B2081CB3A50BD44L ,
113
- 0x90003416F28ACD89L ,
114
- 0x92F252C398C02946L ,
115
- 0x9E404E583F254FD4L ,
116
110
0x9F2E20FB6049A371L ,
117
111
0xA8AAA929446FFCE4L ,
118
- 0xAB9B8D073948CA9DL ,
119
- 0xAFCB539973CEA3F7L ,
120
- 0xB5114C70135C4538L ,
121
- 0xC0FE32B8DC897DE9L ,
122
- 0xC59AA84D9A94C640L ,
123
- 0xC92D8F9129AF339BL ,
124
- 0xCC720543DC5E7090L ,
125
- 0xD0E71A6E155603C1L ,
126
- 0xD11D2A941337A7BCL ,
127
- 0xDB7BFFC197369352L ,
128
- 0xDC9583F0087CC2C7L ,
129
- 0xDDAAA11FECA77B5EL ,
130
- 0xE08EE874A26F5EAFL ,
131
- 0xE794F5F7DCD3AC85L ,
132
- 0xEB7D4786C473368DL ,
133
- 0xF4AA683928027CDAL ,
134
- 0xF8C7EF9B13231FB6L ,
135
112
0xD45D6F8C9017FAL ,
136
- 0x6B949CE6C2FE009L ,
137
- 0x76566C052E83815L ,
138
- 0x9DF9341F0C76702L ,
139
- 0xB81BA299273D4E6L ,
140
- 0xD4788669A13AE74L ,
141
- 0x111D12921C5466DAL ,
142
- 0x178B0E2DC3AE9FE5L ,
143
- 0x19DCAF4ADC37D6D4L ,
144
- 0x1F10A70EE4065963L ,
145
- 0x21082DFBF63FBCC1L ,
146
- 0x24AE2D07FB5D7497L ,
147
- 0x26C5D923AF21E2E1L ,
148
- 0x34CC8E52316FA0CBL ,
149
- 0x3F64BC3933A6A2DFL ,
150
- 0x42646E60EC7E5189L ,
151
- 0x44D57A1B1EF53451L ,
152
- 0x4A39C6C7ACB6AA18L ,
153
- 0x4BB3C59964A2FC50L ,
154
- 0x4F0C3688E8A18F9FL ,
155
- 0x5449EC9B0280B9EFL ,
156
- 0x54DC66A59269BAE1L ,
157
- 0x552D9FB02FFC9DEFL ,
158
- 0x557F642131553498L ,
159
- 0x604D6657082C1EE9L ,
160
- 0x61D10AF54471E5DEL ,
161
- 0x64DC636F343516DCL ,
162
- 0x73A0BE903F2BCBF4L ,
163
- 0x73FBA1E41C4C3553L ,
164
- 0x7B606F16A261E1E6L ,
165
- 0x7F36112F218143B6L ,
166
- 0x7FE2B8E675DA0CEFL
113
+ 0x64DC636F343516DCL
167
114
};
168
115
}
169
116
@@ -1383,6 +1330,11 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
1383
1330
throw new JSONException ("safeMode not support autoType : " + typeName );
1384
1331
}
1385
1332
1333
+ final int mask = Feature .SupportAutoType .mask ;
1334
+ boolean autoTypeSupport = this .autoTypeSupport
1335
+ || (features & mask ) != 0
1336
+ || (JSON .DEFAULT_PARSER_FEATURE & mask ) != 0 ;
1337
+
1386
1338
if (typeName .length () >= 192 || typeName .length () < 3 ) {
1387
1339
throw new JSONException ("autoType is not support. " + typeName );
1388
1340
}
@@ -1500,6 +1452,10 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
1500
1452
hash *= fnv1a_64_magic_prime ;
1501
1453
1502
1454
if (Arrays .binarySearch (denyHashCodes , hash ) >= 0 ) {
1455
+ if (typeName .endsWith ("Exception" ) || typeName .endsWith ("Error" )) {
1456
+ return null ;
1457
+ }
1458
+
1503
1459
throw new JSONException ("autoType is not support. " + typeName );
1504
1460
}
1505
1461
@@ -1541,19 +1497,16 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
1541
1497
IOUtils .close (is );
1542
1498
}
1543
1499
1544
- final int mask = Feature .SupportAutoType .mask ;
1545
- boolean autoTypeSupport = this .autoTypeSupport
1546
- || (features & mask ) != 0
1547
- || (JSON .DEFAULT_PARSER_FEATURE & mask ) != 0 ;
1548
-
1549
1500
if (autoTypeSupport || jsonType || expectClassFlag ) {
1550
1501
boolean cacheClass = autoTypeSupport || jsonType ;
1551
1502
clazz = TypeUtils .loadClass (typeName , defaultClassLoader , cacheClass );
1552
1503
}
1553
1504
1554
1505
if (clazz != null ) {
1555
1506
if (jsonType ) {
1556
- TypeUtils .addMapping (typeName , clazz );
1507
+ if (autoTypeSupport ) {
1508
+ TypeUtils .addMapping (typeName , clazz );
1509
+ }
1557
1510
return clazz ;
1558
1511
}
1559
1512
@@ -1566,7 +1519,9 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
1566
1519
1567
1520
if (expectClass != null ) {
1568
1521
if (expectClass .isAssignableFrom (clazz )) {
1569
- TypeUtils .addMapping (typeName , clazz );
1522
+ if (autoTypeSupport ) {
1523
+ TypeUtils .addMapping (typeName , clazz );
1524
+ }
1570
1525
return clazz ;
1571
1526
} else {
1572
1527
throw new JSONException ("type not match. " + typeName + " -> " + expectClass .getName ());
@@ -1580,15 +1535,17 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
1580
1535
}
1581
1536
1582
1537
if (!autoTypeSupport ) {
1583
- if (typeName .endsWith ("Exception" )) {
1538
+ if (typeName .endsWith ("Exception" ) || typeName . endsWith ( "Error" ) ) {
1584
1539
return null ;
1585
1540
}
1586
1541
1587
1542
throw new JSONException ("autoType is not support. " + typeName );
1588
1543
}
1589
1544
1590
1545
if (clazz != null ) {
1591
- TypeUtils .addMapping (typeName , clazz );
1546
+ if (autoTypeSupport ) {
1547
+ TypeUtils .addMapping (typeName , clazz );
1548
+ }
1592
1549
}
1593
1550
1594
1551
return clazz ;
0 commit comments