Skip to content

Commit

Permalink
HV-1790 Remove the SafeHtml constraint and the jsoup dependency
Browse files Browse the repository at this point in the history
There is no replacement for this constraint.
It has been deprecated and planned for removal in both 6.0 and 6.1.
  • Loading branch information
gsmet committed Dec 4, 2020
1 parent 93c7dd7 commit 55a24f3
Show file tree
Hide file tree
Showing 47 changed files with 5 additions and 985 deletions.
Expand Up @@ -305,7 +305,6 @@ public ConstraintHelper(Types typeUtils, AnnotationApiHelper annotationApiHelper
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NOT_BLANK, CharSequence.class );
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NOT_EMPTY, TYPES_SUPPORTED_BY_SIZE_AND_NOT_EMPTY_ANNOTATIONS );
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NORMALIZED, CharSequence.class );
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.SAFE_HTML, CharSequence.class );
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.SCRIPT_ASSERT, Object.class );
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.UNIQUE_ELEMENTS, Collection.class );
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.URL, CharSequence.class );
Expand Down
Expand Up @@ -81,7 +81,6 @@ public static class HibernateValidatorTypes {
public static final String NORMALIZED = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".Normalized";
public static final String NOT_BLANK = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".NotBlank";
public static final String NOT_EMPTY = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".NotEmpty";
public static final String SAFE_HTML = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".SafeHtml";
public static final String SCRIPT_ASSERT = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".ScriptAssert";
public static final String UNIQUE_ELEMENTS = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".UniqueElements";
public static final String URL = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".URL";
Expand Down
Expand Up @@ -155,6 +155,8 @@ public void hibernateValidatorProvidedCustomConstraints() {
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 66 ),
new DiagnosticExpectation( Kind.ERROR, 67 ),
new DiagnosticExpectation( Kind.ERROR, 68 ),
new DiagnosticExpectation( Kind.ERROR, 69 ),
new DiagnosticExpectation( Kind.ERROR, 70 ),
Expand All @@ -171,10 +173,7 @@ public void hibernateValidatorProvidedCustomConstraints() {
new DiagnosticExpectation( Kind.ERROR, 81 ),
new DiagnosticExpectation( Kind.ERROR, 82 ),
new DiagnosticExpectation( Kind.ERROR, 83 ),
new DiagnosticExpectation( Kind.ERROR, 84 ),
new DiagnosticExpectation( Kind.ERROR, 85 ),
new DiagnosticExpectation( Kind.ERROR, 86 ),
new DiagnosticExpectation( Kind.ERROR, 87 )
new DiagnosticExpectation( Kind.ERROR, 84 )
);
}

Expand Down
Expand Up @@ -19,7 +19,6 @@
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.SafeHtml;
import org.hibernate.validator.constraints.ScriptAssert;
import org.hibernate.validator.constraints.URL;
import org.hibernate.validator.constraints.br.CNPJ;
Expand Down Expand Up @@ -48,7 +47,6 @@ public class HibernateValidatorProvidedCustomConstraints {
@NotBlank
@NotEmpty
@Range
@SafeHtml
@URL
@CNPJ
@CPF
Expand All @@ -75,7 +73,6 @@ public class HibernateValidatorProvidedCustomConstraints {
@NotBlank
@NotEmpty
@Range
@SafeHtml
@URL
@CNPJ
@CPF
Expand Down
4 changes: 0 additions & 4 deletions distribution/pom.xml
Expand Up @@ -65,10 +65,6 @@
<groupId>javax.money</groupId>
<artifactId>money-api</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.paranamer</groupId>
<artifactId>paranamer</artifactId>
Expand Down
1 change: 0 additions & 1 deletion distribution/src/main/assembly/dist.xml
Expand Up @@ -45,7 +45,6 @@
<include>org.apache.logging.log4j:log4j-core</include>
<include>joda-time:joda-time</include>
<include>jakarta.persistence:jakarta.persistence-api</include>
<include>org.jsoup:jsoup</include>
<include>com.thoughtworks.paranamer:paranamer</include>
</includes>
</dependencySet>
Expand Down
5 changes: 0 additions & 5 deletions documentation/src/main/asciidoc/ch02.asciidoc
Expand Up @@ -715,11 +715,6 @@ With one exception also these constraints apply to the field/property level, onl
Supported data types::: `BigDecimal`, `BigInteger`, `CharSequence`, `byte`, `short`, `int`, `long` and the respective wrappers of the primitive types
Hibernate metadata impact::: None

`@SafeHtml(whitelistType= , additionalTags=, additionalTagsWithAttributes=, baseURI=)`:: Checks whether the annotated value contains potentially malicious fragments such as `<script/>`. In order to use this constraint, the http://jsoup.org/[jsoup] library must be part of the class path. With the `whitelistType` attribute a predefined whitelist type can be chosen which can be refined via `additionalTags` or `additionalTagsWithAttributes`. The former allows to add tags without any attributes, whereas the latter allows to specify tags and optionally allowed attributes as well as accepted protocols for the attributes using the annotation `@SafeHtml.Tag`.
In addition, `baseURI` allows to specify the base URI used to resolve relative URIs.
Supported data types::: `CharSequence`
Hibernate metadata impact::: None

`@ScriptAssert(lang=, script=, alias=, reportOn=)`:: Checks whether the given script can successfully be evaluated against the annotated element. In order to use this constraint, an implementation of the Java Scripting API as defined by JSR 223 ("Scripting for the Java^TM^ Platform") must be a part of the class path. The expressions to be evaluated can be written in any scripting or expression language, for which a JSR 223 compatible engine can be found in the class path. Even though this is a class-level constraint, one can use the `reportOn` attribute to report a constraint violation on a specific property rather than the whole object.
Supported data types::: Any type
Hibernate metadata impact::: None
Expand Down
6 changes: 0 additions & 6 deletions engine/pom.xml
Expand Up @@ -89,11 +89,6 @@
<artifactId>joda-time</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.thoughtworks.paranamer</groupId>
<artifactId>paranamer</artifactId>
Expand Down Expand Up @@ -251,7 +246,6 @@
org.jboss.logging.*;version="[3.1.0,4.0.0)",
com.fasterxml.classmate.*;version="[1.3,2.0.0)",
org.joda.time.*;version="[2.0.0,3.0.0)";resolution:=optional,
org.jsoup.*;version="[1.5.2,2.0.0)";resolution:=optional,
javax.money;version="[1.0.0,2.0.0)";resolution:=optional,
com.thoughtworks.paranamer.*;version="[2.5.5,3.0.0)";resolution:=optional
</Import-Package>
Expand Down
140 changes: 0 additions & 140 deletions engine/src/main/java/org/hibernate/validator/cfg/defs/SafeHtmlDef.java

This file was deleted.

0 comments on commit 55a24f3

Please sign in to comment.