Skip to content

Commit

Permalink
Merge pull request #927 from HubSpot/revert-926-revert-925-master
Browse files Browse the repository at this point in the history
Shade and upgrade jsoup to 1.15.3
  • Loading branch information
jasmith-hs authored Jun 12, 2023
2 parents 975dddd + f3c7e03 commit 1a909fc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.2</version>
<version>1.15.3</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
Expand Down Expand Up @@ -235,6 +235,7 @@
<includes>
<include>de.odysseus.juel:juel-api</include>
<include>de.odysseus.juel:juel-impl</include>
<include>org.jsoup:jsoup</include>
</includes>
</artifactSet>
<relocations>
Expand All @@ -246,6 +247,10 @@
<pattern>de.odysseus.el</pattern>
<shadedPattern>jinjava.de.odysseus.el</shadedPattern>
</relocation>
<relocation>
<pattern>org.jsoup</pattern>
<shadedPattern>jinjava.org.jsoup</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
import java.util.regex.Pattern;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import org.jsoup.safety.Safelist;

/**
* striptags(value) Strip SGML/XML tags and replace adjacent whitespace by one space.
Expand Down Expand Up @@ -43,7 +43,7 @@ public Object filter(Object object, JinjavaInterpreter interpreter, String... ar
}

String cleanedVal = Jsoup.parse(val).text();
cleanedVal = Jsoup.clean(cleanedVal, Whitelist.none());
cleanedVal = Jsoup.clean(cleanedVal, Safelist.none());

// backwards compatibility with Jsoup.parse
cleanedVal = cleanedVal.replaceAll("&nbsp;", " ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public void itPreservesEndTagsWhenTruncatingWithinTagContent() {
"33"
);
assertThat(result)
.isEqualTo(
"<h1>HTML Ipsum Presents</h1> \n<p><strong>Pellentesque...</strong></p>"
);
.isEqualTo("<h1>HTML Ipsum Presents</h1>\n<p><strong>Pellentesque...</strong></p>");
}

@Test
Expand All @@ -39,9 +37,7 @@ public void itDoesntChopWordsWhenSpecified() {
"35"
);
assertThat(result)
.isEqualTo(
"<h1>HTML Ipsum Presents</h1> \n<p><strong>Pellentesque...</strong></p>"
);
.isEqualTo("<h1>HTML Ipsum Presents</h1>\n<p><strong>Pellentesque...</strong></p>");

result =
(String) filter.filter(
Expand All @@ -53,7 +49,7 @@ public void itDoesntChopWordsWhenSpecified() {
);
assertThat(result)
.isEqualTo(
"<h1>HTML Ipsum Presents</h1> \n<p><strong>Pellentesque ha...</strong></p>"
"<h1>HTML Ipsum Presents</h1>\n<p><strong>Pellentesque ha...</strong></p>"
);
}

Expand All @@ -66,9 +62,7 @@ public void itTakesKwargs() {
ImmutableMap.of("breakwords", false)
);
assertThat(result)
.isEqualTo(
"<h1>HTML Ipsum Presents</h1> \n<p><strong>Pellentesque...</strong></p>"
);
.isEqualTo("<h1>HTML Ipsum Presents</h1>\n<p><strong>Pellentesque...</strong></p>");

result =
(String) filter.filter(
Expand All @@ -79,7 +73,7 @@ public void itTakesKwargs() {
);
assertThat(result)
.isEqualTo(
"<h1>HTML Ipsum Presents</h1> \n<p><strong>PellentesqueTEST</strong></p>"
"<h1>HTML Ipsum Presents</h1>\n<p><strong>PellentesqueTEST</strong></p>"
);
}

Expand Down

0 comments on commit 1a909fc

Please sign in to comment.