Browse Source

Merge branch '5.3.x'

pull/27700/head
Brian Clozel 4 years ago
parent
commit
f3b83e7ad4
  1. 4
      spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityDecoder.java
  2. 10
      spring-web/src/test/java/org/springframework/web/util/HtmlUtilsTests.java

4
spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityDecoder.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -72,7 +72,7 @@ class HtmlCharacterEntityDecoder { @@ -72,7 +72,7 @@ class HtmlCharacterEntityDecoder {
boolean isPotentialReference = (this.nextPotentialReferencePosition != -1 &&
this.nextSemicolonPosition != -1 &&
this.nextPotentialReferencePosition - this.nextSemicolonPosition < MAX_REFERENCE_SIZE);
this.nextSemicolonPosition - this.nextPotentialReferencePosition < MAX_REFERENCE_SIZE);
if (isPotentialReference) {
break;

10
spring-web/src/test/java/org/springframework/web/util/HtmlUtilsTests.java

@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class HtmlUtilsTests {
@Test
public void testHtmlEscape() {
void testHtmlEscape() {
String unescaped = "\"This is a quote'";
String escaped = HtmlUtils.htmlEscape(unescaped);
assertThat(escaped).isEqualTo("&quot;This is a quote&#39;");
@ -39,14 +39,14 @@ public class HtmlUtilsTests { @@ -39,14 +39,14 @@ public class HtmlUtilsTests {
}
@Test
public void testHtmlUnescape() {
void testHtmlUnescape() {
String escaped = "&quot;This is a quote&#39;";
String unescaped = HtmlUtils.htmlUnescape(escaped);
assertThat(unescaped).isEqualTo("\"This is a quote'");
}
@Test
public void testEncodeIntoHtmlCharacterSet() {
void testEncodeIntoHtmlCharacterSet() {
assertThat(HtmlUtils.htmlEscape("")).as("An empty string should be converted to an empty string").isEqualTo("");
assertThat(HtmlUtils.htmlEscape("A sentence containing no special characters.")).as("A string containing no special characters should not be affected").isEqualTo("A sentence containing no special characters.");
@ -62,7 +62,7 @@ public class HtmlUtilsTests { @@ -62,7 +62,7 @@ public class HtmlUtilsTests {
// SPR-9293
@Test
public void testEncodeIntoHtmlCharacterSetFromUtf8() {
void testEncodeIntoHtmlCharacterSetFromUtf8() {
String utf8 = ("UTF-8");
assertThat(HtmlUtils.htmlEscape("", utf8)).as("An empty string should be converted to an empty string").isEqualTo("");
assertThat(HtmlUtils.htmlEscape("A sentence containing no special characters.")).as("A string containing no special characters should not be affected").isEqualTo("A sentence containing no special characters.");
@ -74,7 +74,7 @@ public class HtmlUtilsTests { @@ -74,7 +74,7 @@ public class HtmlUtilsTests {
}
@Test
public void testDecodeFromHtmlCharacterSet() {
void testDecodeFromHtmlCharacterSet() {
assertThat(HtmlUtils.htmlUnescape("")).as("An empty string should be converted to an empty string").isEqualTo("");
assertThat(HtmlUtils.htmlUnescape("This is a sentence containing no special characters.")).as("A string containing no special characters should not be affected").isEqualTo("This is a sentence containing no special characters.");

Loading…
Cancel
Save