Skip to content

Commit 55a24f3

Browse files
committed
HV-1790 Remove the SafeHtml constraint and the jsoup dependency
There is no replacement for this constraint. It has been deprecated and planned for removal in both 6.0 and 6.1.
1 parent 93c7dd7 commit 55a24f3

File tree

47 files changed

+5
-985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+5
-985
lines changed

annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/ConstraintHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ public ConstraintHelper(Types typeUtils, AnnotationApiHelper annotationApiHelper
305305
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NOT_BLANK, CharSequence.class );
306306
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NOT_EMPTY, TYPES_SUPPORTED_BY_SIZE_AND_NOT_EMPTY_ANNOTATIONS );
307307
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NORMALIZED, CharSequence.class );
308-
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.SAFE_HTML, CharSequence.class );
309308
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.SCRIPT_ASSERT, Object.class );
310309
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.UNIQUE_ELEMENTS, Collection.class );
311310
registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.URL, CharSequence.class );

annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/TypeNames.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public static class HibernateValidatorTypes {
8181
public static final String NORMALIZED = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".Normalized";
8282
public static final String NOT_BLANK = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".NotBlank";
8383
public static final String NOT_EMPTY = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".NotEmpty";
84-
public static final String SAFE_HTML = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".SafeHtml";
8584
public static final String SCRIPT_ASSERT = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".ScriptAssert";
8685
public static final String UNIQUE_ELEMENTS = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".UniqueElements";
8786
public static final String URL = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".URL";

annotation-processor/src/test/java/org/hibernate/validator/ap/ConstraintValidationProcessorTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ public void hibernateValidatorProvidedCustomConstraints() {
155155
assertFalse( compilationResult );
156156
assertThatDiagnosticsMatch(
157157
diagnostics,
158+
new DiagnosticExpectation( Kind.ERROR, 66 ),
159+
new DiagnosticExpectation( Kind.ERROR, 67 ),
158160
new DiagnosticExpectation( Kind.ERROR, 68 ),
159161
new DiagnosticExpectation( Kind.ERROR, 69 ),
160162
new DiagnosticExpectation( Kind.ERROR, 70 ),
@@ -171,10 +173,7 @@ public void hibernateValidatorProvidedCustomConstraints() {
171173
new DiagnosticExpectation( Kind.ERROR, 81 ),
172174
new DiagnosticExpectation( Kind.ERROR, 82 ),
173175
new DiagnosticExpectation( Kind.ERROR, 83 ),
174-
new DiagnosticExpectation( Kind.ERROR, 84 ),
175-
new DiagnosticExpectation( Kind.ERROR, 85 ),
176-
new DiagnosticExpectation( Kind.ERROR, 86 ),
177-
new DiagnosticExpectation( Kind.ERROR, 87 )
176+
new DiagnosticExpectation( Kind.ERROR, 84 )
178177
);
179178
}
180179

annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/customconstraints/HibernateValidatorProvidedCustomConstraints.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.hibernate.validator.constraints.NotBlank;
2020
import org.hibernate.validator.constraints.NotEmpty;
2121
import org.hibernate.validator.constraints.Range;
22-
import org.hibernate.validator.constraints.SafeHtml;
2322
import org.hibernate.validator.constraints.ScriptAssert;
2423
import org.hibernate.validator.constraints.URL;
2524
import org.hibernate.validator.constraints.br.CNPJ;
@@ -48,7 +47,6 @@ public class HibernateValidatorProvidedCustomConstraints {
4847
@NotBlank
4948
@NotEmpty
5049
@Range
51-
@SafeHtml
5250
@URL
5351
@CNPJ
5452
@CPF
@@ -75,7 +73,6 @@ public class HibernateValidatorProvidedCustomConstraints {
7573
@NotBlank
7674
@NotEmpty
7775
@Range
78-
@SafeHtml
7976
@URL
8077
@CNPJ
8178
@CPF

distribution/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@
6565
<groupId>javax.money</groupId>
6666
<artifactId>money-api</artifactId>
6767
</dependency>
68-
<dependency>
69-
<groupId>org.jsoup</groupId>
70-
<artifactId>jsoup</artifactId>
71-
</dependency>
7268
<dependency>
7369
<groupId>com.thoughtworks.paranamer</groupId>
7470
<artifactId>paranamer</artifactId>

distribution/src/main/assembly/dist.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
<include>org.apache.logging.log4j:log4j-core</include>
4646
<include>joda-time:joda-time</include>
4747
<include>jakarta.persistence:jakarta.persistence-api</include>
48-
<include>org.jsoup:jsoup</include>
4948
<include>com.thoughtworks.paranamer:paranamer</include>
5049
</includes>
5150
</dependencySet>

documentation/src/main/asciidoc/ch02.asciidoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,6 @@ With one exception also these constraints apply to the field/property level, onl
715715
Supported data types::: `BigDecimal`, `BigInteger`, `CharSequence`, `byte`, `short`, `int`, `long` and the respective wrappers of the primitive types
716716
Hibernate metadata impact::: None
717717

718-
`@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`.
719-
In addition, `baseURI` allows to specify the base URI used to resolve relative URIs.
720-
Supported data types::: `CharSequence`
721-
Hibernate metadata impact::: None
722-
723718
`@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.
724719
Supported data types::: Any type
725720
Hibernate metadata impact::: None

engine/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@
8989
<artifactId>joda-time</artifactId>
9090
<optional>true</optional>
9191
</dependency>
92-
<dependency>
93-
<groupId>org.jsoup</groupId>
94-
<artifactId>jsoup</artifactId>
95-
<optional>true</optional>
96-
</dependency>
9792
<dependency>
9893
<groupId>com.thoughtworks.paranamer</groupId>
9994
<artifactId>paranamer</artifactId>
@@ -251,7 +246,6 @@
251246
org.jboss.logging.*;version="[3.1.0,4.0.0)",
252247
com.fasterxml.classmate.*;version="[1.3,2.0.0)",
253248
org.joda.time.*;version="[2.0.0,3.0.0)";resolution:=optional,
254-
org.jsoup.*;version="[1.5.2,2.0.0)";resolution:=optional,
255249
javax.money;version="[1.0.0,2.0.0)";resolution:=optional,
256250
com.thoughtworks.paranamer.*;version="[2.5.5,3.0.0)";resolution:=optional
257251
</Import-Package>

engine/src/main/java/org/hibernate/validator/cfg/defs/SafeHtmlDef.java

Lines changed: 0 additions & 140 deletions
This file was deleted.

0 commit comments

Comments
 (0)