Skip to content

Commit 0d0f01b

Browse files
committed
Merge branch '2.10' of https://github.com/FasterXML/jackson-databind into 2.10
2 parents 865c43f + 555cbeb commit 0d0f01b

32 files changed

+217
-63
lines changed

release-notes/CREDITS-2.x

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,10 @@ Guixiong Wu (吴桂雄)
653653
* Reported #2032: Blacklist another serialization gadget (ibatis)
654654
(2.8.11.2)
655655

656+
svarzee@github
657+
* Reported #2109, suggested fix: Canonical string for reference type is built incorrectly
658+
(2.8.11.3 / 2.9.7)
659+
656660
Connor Kuhn (ckuhn@github)
657661
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
658662
(2.9.0)
@@ -806,3 +810,11 @@ Petar Tahchiev (ptahchiev@github)
806810
Thibaut Robert (trobert@github)
807811
* Requested #2059: Remove `final` modifier for `TypeFactory`
808812
(2.10.0)
813+
814+
Christopher Smith (chrylis@github)
815+
* Suggested #2115: Support naive deserialization of `Serializable` values as "untyped",
816+
same as `java.lang.Object`
817+
(2.10.0)
818+
819+
Édouard Mercier (edouardmercier@github)
820+
* Requested #2116: Make NumberSerializers.Base public and its inherited classes not final

release-notes/VERSION-2.x

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,29 @@ Project: jackson-databind
88

99
#2059: Remove `final` modifier for `TypeFactory`
1010
(requested by Thibaut R)
11+
#2115: Support naive deserialization of `Serializable` values as "untyped", same
12+
as `java.lang.Object`
13+
(requested by Christopher S)
14+
#2116: Make NumberSerializers.Base public and its inherited classes not final
15+
(requested by Édouard M)
1116

1217
2.9.7 (not yet released)
1318

1419
#2060: `UnwrappingBeanPropertyWriter` incorrectly assumes the found serializer is
1520
of type `UnwrappingBeanSerializer`
1621
(reported by Petar T)
22+
#2079: NPE when visiting StaticListSerializerBase
23+
(reported by WorldSEnder@github)
1724
#2082: `FactoryBasedEnumDeserializer` should be cachable
25+
#2088: `@JsonUnwrapped` fields are skipped when using `PropertyBasedCreator` if
26+
they appear after the last creator property
27+
(reported, fix contributed by 6bangs@github)
28+
#2096: `TreeTraversingParser` does not take base64 variant into account
29+
(reported by tangiel@github)
30+
#2097: Block more classes from polymorphic deserialization (CVE-2018-14718
31+
- CVE-2018-14721)
32+
#2109: Canonical string for reference type is built incorrectly
33+
(reported by svarzee@github)
1834

1935
2.9.6 (12-Jun-2018)
2036

@@ -581,9 +597,10 @@ Project: jackson-databind
581597
#1225: `JsonMappingException` should override getProcessor()
582598
(reported by Nick B)
583599

584-
2.6.8 (if ever released)
600+
2.6.7.1 (11-Jul-2017)
585601

586602
#1383: Problem with `@JsonCreator` with 1-arg factory-method, implicit param names
603+
#1599: Backport the extra safety checks for polymorphic deserialization
587604

588605
2.6.7 (05-Jun-2016)
589606

src/main/java/com/fasterxml/jackson/databind/DeserializationContext.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,15 +1589,21 @@ public JsonMappingException weirdNativeValueException(Object value, Class<?> ins
15891589
* to indicate problem with physically constructing instance of
15901590
* specified class (missing constructor, exception from constructor)
15911591
*<p>
1592-
* Note that most of the time this method should NOT be called; instead,
1592+
* Note that most of the time this method should NOT be called directly; instead,
15931593
* {@link #handleInstantiationProblem} should be called which will call this method
15941594
* if necessary.
15951595
*/
15961596
public JsonMappingException instantiationException(Class<?> instClass, Throwable cause) {
15971597
// Most likely problem with Creator definition, right?
1598-
JavaType type = constructType(instClass);
1598+
final JavaType type = constructType(instClass);
1599+
String excMsg;
1600+
if (cause == null) {
1601+
excMsg = "N/A";
1602+
} else if ((excMsg = cause.getMessage()) == null) {
1603+
excMsg = ClassUtil.nameOf(cause.getClass());
1604+
}
15991605
String msg = String.format("Cannot construct instance of %s, problem: %s",
1600-
ClassUtil.nameOf(instClass), cause.getMessage());
1606+
ClassUtil.nameOf(instClass), excMsg);
16011607
InvalidDefinitionException e = InvalidDefinitionException.from(_parser, msg, type);
16021608
e.initCause(cause);
16031609
return e;

src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ protected ClassIntrospector defaultClassIntrospector() {
621621
* return builder(JsonFactory.builder().build());
622622
*</pre>
623623
*
624-
* @since 2.9
624+
* @since 2.10
625625
*/
626626
@SuppressWarnings("unchecked")
627627
public static <M extends ObjectMapper, B extends MapperBuilder<M,B>> MapperBuilder<M,B> builder() {

src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.fasterxml.jackson.databind.deser;
22

3+
import java.io.Serializable;
34
import java.util.*;
45
import java.util.concurrent.*;
56
import java.util.concurrent.atomic.AtomicReference;
@@ -8,8 +9,10 @@
89
import com.fasterxml.jackson.annotation.JsonCreator;
910
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1011
import com.fasterxml.jackson.annotation.JsonCreator.Mode;
12+
1113
import com.fasterxml.jackson.core.JsonLocation;
1214
import com.fasterxml.jackson.core.JsonParser;
15+
1316
import com.fasterxml.jackson.databind.*;
1417
import com.fasterxml.jackson.databind.cfg.DeserializerFactoryConfig;
1518
import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
@@ -46,6 +49,7 @@ public abstract class BasicDeserializerFactory
4649
private final static Class<?> CLASS_CHAR_SEQUENCE = CharSequence.class;
4750
private final static Class<?> CLASS_ITERABLE = Iterable.class;
4851
private final static Class<?> CLASS_MAP_ENTRY = Map.Entry.class;
52+
private final static Class<?> CLASS_SERIALIZABLE = Serializable.class;
4953

5054
/**
5155
* We need a placeholder for creator properties that don't have name
@@ -1771,8 +1775,8 @@ public JsonDeserializer<?> findDefaultDeserializer(DeserializationContext ctxt,
17711775
throws JsonMappingException
17721776
{
17731777
Class<?> rawType = type.getRawClass();
1774-
// Object ("untyped"), String equivalents:
1775-
if (rawType == CLASS_OBJECT) {
1778+
// Object ("untyped"), and as of 2.10 (see [databind#2115]), `java.io.Serializable`
1779+
if ((rawType == CLASS_OBJECT) || (rawType == CLASS_SERIALIZABLE)) {
17761780
// 11-Feb-2015, tatu: As per [databind#700] need to be careful wrt non-default Map, List.
17771781
DeserializationConfig config = ctxt.getConfig();
17781782
JavaType lt, mt;
@@ -1785,6 +1789,7 @@ public JsonDeserializer<?> findDefaultDeserializer(DeserializationContext ctxt,
17851789
}
17861790
return new UntypedObjectDeserializer(lt, mt);
17871791
}
1792+
// String and equivalents
17881793
if (rawType == CLASS_STRING || rawType == CLASS_CHAR_SEQUENCE) {
17891794
return StringDeserializer.instance;
17901795
}

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,17 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
767767
p.setCurrentValue(bean);
768768
// if so, need to copy all remaining tokens into buffer
769769
while (t == JsonToken.FIELD_NAME) {
770-
p.nextToken(); // to skip name
770+
// NOTE: do NOT skip name as it needs to be copied; `copyCurrentStructure` does that
771771
tokens.copyCurrentStructure(p);
772772
t = p.nextToken();
773773
}
774+
// 28-Aug-2018, tatu: Let's add sanity check here, easier to catch off-by-some
775+
// problems if we maintain invariants
776+
if (t != JsonToken.END_OBJECT) {
777+
ctxt.reportWrongTokenException(this, JsonToken.END_OBJECT,
778+
"Attempted to unwrap '%s' value",
779+
handledType().getName());
780+
}
774781
tokens.writeEndObject();
775782
if (bean.getClass() != _beanType.getRawClass()) {
776783
// !!! 08-Jul-2011, tatu: Could probably support; but for now

src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fasterxml.jackson.databind.deser.std;
22

33
import java.io.IOException;
4+
import java.io.Serializable;
45
import java.lang.reflect.Constructor;
56
import java.lang.reflect.Method;
67
import java.net.MalformedURLException;
@@ -72,9 +73,13 @@ public static StdKeyDeserializer forType(Class<?> raw)
7273
int kind;
7374

7475
// first common types:
75-
if (raw == String.class || raw == Object.class || raw == CharSequence.class) {
76+
if (raw == String.class || raw == Object.class
77+
|| raw == CharSequence.class
78+
// see [databind#2115]:
79+
|| raw == Serializable.class) {
7680
return StringKD.forType(raw);
77-
} else if (raw == UUID.class) {
81+
}
82+
if (raw == UUID.class) {
7883
kind = TYPE_UUID;
7984
} else if (raw == Integer.class) {
8085
kind = TYPE_INT;

src/main/java/com/fasterxml/jackson/databind/deser/std/StdKeyDeserializers.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ public static KeyDeserializer constructDelegatingKeyDeserializer(Deserialization
4848
public static KeyDeserializer findStringBasedKeyDeserializer(DeserializationConfig config,
4949
JavaType type)
5050
{
51-
/* We don't need full deserialization information, just need to
52-
* know creators.
53-
*/
51+
// We don't need full deserialization information, just need to know creators.
5452
BeanDescription beanDesc = config.introspect(type);
5553
// Ok, so: can we find T(String) constructor?
5654
Constructor<?> ctor = beanDesc.findSingleArgConstructor(String.class);

src/main/java/com/fasterxml/jackson/databind/jsontype/impl/SubTypeValidator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public class SubTypeValidator
6868
s.add("oracle.jdbc.connector.OracleManagedConnectionFactory");
6969
s.add("oracle.jdbc.rowset.OracleJDBCRowSet");
7070

71+
// [databind#2097]: some 3rd party, one JDK-bundled
72+
s.add("org.slf4j.ext.EventData");
73+
s.add("flex.messaging.util.concurrent.AsynchBeansWorkManagerExecutor");
74+
s.add("com.sun.deploy.security.ruleset.DRSHelper");
75+
s.add("org.apache.axis2.jaxws.spi.handler.HandlerResolverImpl");
76+
7177
DEFAULT_NO_DESER_CLASS_NAMES = Collections.unmodifiableSet(s);
7278
}
7379

src/main/java/com/fasterxml/jackson/databind/node/TreeTraversingParser.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -357,19 +357,13 @@ public byte[] getBinaryValue(Base64Variant b64variant)
357357
{
358358
// Multiple possibilities...
359359
JsonNode n = currentNode();
360-
if (n != null) { // binary node?
361-
byte[] data = n.binaryValue();
362-
// (or TextNode, which can also convert automatically!)
363-
if (data != null) {
364-
return data;
365-
}
366-
// Or maybe byte[] as POJO?
367-
if (n.isPojo()) {
368-
Object ob = ((POJONode) n).getPojo();
369-
if (ob instanceof byte[]) {
370-
return (byte[]) ob;
371-
}
360+
if (n != null) {
361+
// [databind#2096]: although `binaryValue()` works for real binary node
362+
// and embedded "POJO" node, coercion from TextNode may require variant, so:
363+
if (n instanceof TextNode) {
364+
return ((TextNode) n).getBinaryValue(b64variant);
372365
}
366+
return n.binaryValue();
373367
}
374368
// otherwise return null to mark we have no binary content
375369
return null;

0 commit comments

Comments
 (0)