Skip to content

Commit

Permalink
Bump jsoup from 1.10.2 to 1.15.3 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe authored Sep 3, 2022
1 parent d7fec9f commit e8dbed1
Show file tree
Hide file tree
Showing 12 changed files with 536 additions and 538 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.2</version>
<version>1.15.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/gitbucket/markedj/Marked.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.gitbucket.markedj;

import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import org.jsoup.safety.Safelist;

public class Marked {

Expand All @@ -20,7 +20,7 @@ public static String marked(String src, Options options, Renderer renderer){
Parser parser = new Parser(options, renderer);
String html = parser.parse(result.getTokens(), result.getLinks());

Whitelist whitelist = options.getWhitelist();
Safelist whitelist = options.getSafelist();

if(whitelist != null) {
return Jsoup.clean(html, whitelist);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/github/gitbucket/markedj/Options.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.gitbucket.markedj;

import org.jsoup.safety.Whitelist;
import org.jsoup.safety.Safelist;

public class Options {

Expand All @@ -10,7 +10,7 @@ public class Options {
private boolean sanitize = false;
private String langPrefix = "lang-";
private String headerPrefix = "";
private Whitelist whitelist = new Whitelist()
private Safelist safelist = new Safelist()
.addTags(
"a", "b", "blockquote", "br", "caption", "cite", "code", "col",
"colgroup", "dd", "div", "dl", "dt", "em", "h1", "h2", "h3", "h4", "h5", "h6",
Expand Down Expand Up @@ -57,8 +57,8 @@ public void setHeaderPrefix(String headerPrefix) {
this.headerPrefix = headerPrefix;
}

public void setWhitelist(Whitelist whitelist){
this.whitelist = whitelist;
public void setSafelist(Safelist whitelist){
this.safelist = safelist;
}

public boolean isGfm() {
Expand All @@ -85,8 +85,8 @@ public String getHeaderPrefix() {
return headerPrefix;
}

public Whitelist getWhitelist(){
return whitelist;
public Safelist getSafelist(){
return safelist;
}

}
60 changes: 29 additions & 31 deletions src/test/java/io/github/gitbucket/markedj/MarkedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ public void testParagraphSeparation() throws Exception {
"- List B", new Options());

assertEquals(
"<p>Message A</p> \n" +
"<ul> \n" +
" <li>List A</li> \n" +
" <li>List B</li> \n" +
"<p>Message A</p>\n" +
"<ul>\n" +
" <li>List A</li>\n" +
" <li>List B</li>\n" +
"</ul>", result);
}

Expand All @@ -189,26 +189,26 @@ public void testEmptyTableCell() throws Exception {


assertEquals(
"<table> \n" +
" <thead> \n" +
" <tr> \n" +
" <th>ID</th> \n" +
" <th>name</th> \n" +
" <th>note</th> \n" +
" </tr> \n" +
" </thead> \n" +
" <tbody> \n" +
" <tr> \n" +
" <td>1</td> \n" +
" <td>foo</td> \n" +
" <td>This is foo</td> \n" +
" </tr> \n" +
" <tr> \n" +
" <td>2</td> \n" +
" <td>bar</td> \n" +
" <td></td> \n" +
" </tr> \n" +
" </tbody> \n" +
"<table>\n" +
" <thead>\n" +
" <tr>\n" +
" <th>ID</th>\n" +
" <th>name</th>\n" +
" <th>note</th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td>1</td>\n" +
" <td>foo</td>\n" +
" <td>This is foo</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>2</td>\n" +
" <td>bar</td>\n" +
" <td></td>\n" +
" </tr>\n" +
" </tbody>\n" +
"</table>", result);
}

Expand All @@ -231,11 +231,9 @@ public void testSanitize() throws Exception {
options.setSanitize(false);
String result = Marked.marked("- <b>test", options);
// It's not clean but tag is closed at least.
assertEquals("<ul> \n" +
" <li><b>test</b></li>\n" +
" <b> </b>\n" +
"</ul>\n" +
"<b> </b>", result);
assertEquals("<ul>\n" +
" <li><b>test</b></li><b> </b>\n" +
"</ul><b> </b>", result);
}
}

Expand All @@ -247,8 +245,8 @@ public void testHr() throws Exception {
"--------------------------\n" +
"This is a paragraph after a horizontal rule");

assertEquals("<p>This is a paragraph</p> \n" +
"<hr> \n" +
assertEquals("<p>This is a paragraph</p>\n" +
"<hr>\n" +
"<p>This is a paragraph after a horizontal rule</p>", result);
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/resources/empty_item_of_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul>
<li>foo</li>
<li></li>
<li>bar</li>
<ul>
<li>foo</li>
<li></li>
<li>bar</li>
</ul>
Loading

0 comments on commit e8dbed1

Please sign in to comment.