@@ -107,63 +107,10 @@ public class ParserConfig {
107107 }
108108
109109 INTERNAL_WHITELIST_HASHCODES = new long [] {
110- 0x82E8E13016B73F9EL ,
111- 0x863D2DD1E82B9ED9L ,
112- 0x8B2081CB3A50BD44L ,
113- 0x90003416F28ACD89L ,
114- 0x92F252C398C02946L ,
115- 0x9E404E583F254FD4L ,
116110 0x9F2E20FB6049A371L ,
117111 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 ,
135112 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
167114 };
168115 }
169116
@@ -1383,6 +1330,11 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
13831330 throw new JSONException ("safeMode not support autoType : " + typeName );
13841331 }
13851332
1333+ final int mask = Feature .SupportAutoType .mask ;
1334+ boolean autoTypeSupport = this .autoTypeSupport
1335+ || (features & mask ) != 0
1336+ || (JSON .DEFAULT_PARSER_FEATURE & mask ) != 0 ;
1337+
13861338 if (typeName .length () >= 192 || typeName .length () < 3 ) {
13871339 throw new JSONException ("autoType is not support. " + typeName );
13881340 }
@@ -1500,6 +1452,10 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
15001452 hash *= fnv1a_64_magic_prime ;
15011453
15021454 if (Arrays .binarySearch (denyHashCodes , hash ) >= 0 ) {
1455+ if (typeName .endsWith ("Exception" ) || typeName .endsWith ("Error" )) {
1456+ return null ;
1457+ }
1458+
15031459 throw new JSONException ("autoType is not support. " + typeName );
15041460 }
15051461
@@ -1541,19 +1497,16 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
15411497 IOUtils .close (is );
15421498 }
15431499
1544- final int mask = Feature .SupportAutoType .mask ;
1545- boolean autoTypeSupport = this .autoTypeSupport
1546- || (features & mask ) != 0
1547- || (JSON .DEFAULT_PARSER_FEATURE & mask ) != 0 ;
1548-
15491500 if (autoTypeSupport || jsonType || expectClassFlag ) {
15501501 boolean cacheClass = autoTypeSupport || jsonType ;
15511502 clazz = TypeUtils .loadClass (typeName , defaultClassLoader , cacheClass );
15521503 }
15531504
15541505 if (clazz != null ) {
15551506 if (jsonType ) {
1556- TypeUtils .addMapping (typeName , clazz );
1507+ if (autoTypeSupport ) {
1508+ TypeUtils .addMapping (typeName , clazz );
1509+ }
15571510 return clazz ;
15581511 }
15591512
@@ -1566,7 +1519,9 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
15661519
15671520 if (expectClass != null ) {
15681521 if (expectClass .isAssignableFrom (clazz )) {
1569- TypeUtils .addMapping (typeName , clazz );
1522+ if (autoTypeSupport ) {
1523+ TypeUtils .addMapping (typeName , clazz );
1524+ }
15701525 return clazz ;
15711526 } else {
15721527 throw new JSONException ("type not match. " + typeName + " -> " + expectClass .getName ());
@@ -1580,15 +1535,17 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
15801535 }
15811536
15821537 if (!autoTypeSupport ) {
1583- if (typeName .endsWith ("Exception" )) {
1538+ if (typeName .endsWith ("Exception" ) || typeName . endsWith ( "Error" ) ) {
15841539 return null ;
15851540 }
15861541
15871542 throw new JSONException ("autoType is not support. " + typeName );
15881543 }
15891544
15901545 if (clazz != null ) {
1591- TypeUtils .addMapping (typeName , clazz );
1546+ if (autoTypeSupport ) {
1547+ TypeUtils .addMapping (typeName , clazz );
1548+ }
15921549 }
15931550
15941551 return clazz ;
0 commit comments