Skip to content

Commit

Permalink
Strip HTML from OPDS entry summaries (PP-1901).
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Nov 20, 2024
1 parent 154203f commit a450c48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions simplified-opds-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
implementation(libs.jackson.databind)
implementation(libs.javax.annotation.api)
implementation(libs.joda.time)
implementation(libs.jsoup)
implementation(libs.kotlin.reflect)
implementation(libs.kotlin.stdlib)
implementation(libs.slf4j)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.io7m.jnull.Nullable;

import org.joda.time.DateTime;
import org.jsoup.Jsoup;
import org.nypl.simplified.parser.api.ParseError;

import java.io.Serializable;
Expand Down Expand Up @@ -721,7 +722,12 @@ public OPDSAcquisitionFeedEntryBuilderType setSummaryOption(
if (text.isNone()) {
this.summary = "";
} else {
this.summary = ((Some<String>) text).get();
final String s = ((Some<String>) text).get();
try {
this.summary = Jsoup.parse(s).text();
} catch (final Exception e) {
this.summary = s;
}
}
return this;
}
Expand Down
1 change: 1 addition & 0 deletions simplified-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ val dependencyObjects = listOf(
libs.javax.inject,
libs.jcip.annotations,
libs.joda.time,
libs.jsoup,
libs.junit,
libs.junit.jupiter.api,
libs.junit.jupiter.engine,
Expand Down

0 comments on commit a450c48

Please sign in to comment.