Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of the term whitelist #313

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/smithy-go-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ dependencies {
api("software.amazon.smithy:smithy-codegen-core:[1.3.0,2.0.0[")
implementation("software.amazon.smithy:smithy-waiters:[1.4.0,2.0.0[")
compile("com.atlassian.commonmark:commonmark:0.15.2")
api("org.jsoup:jsoup:1.13.1")
api("org.jsoup:jsoup:1.14.1")
implementation("software.amazon.smithy:smithy-protocol-test-traits:[1.3.0,2.0.0[")
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.jsoup.Jsoup;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import org.jsoup.safety.Whitelist;
import org.jsoup.safety.Safelist;
import org.jsoup.select.NodeTraversor;
import org.jsoup.select.NodeVisitor;
import software.amazon.smithy.utils.CodeWriter;
Expand All @@ -39,9 +39,9 @@
*/
public final class DocumentationConverter {
// godoc only supports text blocks, root-level non-inline code blocks, headers, and links.
// This whitelist strips out anything we can't reasonably convert, vastly simplifying the
// This allowlist strips out anything we can't reasonably convert, vastly simplifying the
// node tree we end up having to crawl through.
private static final Whitelist GODOC_WHITELIST = new Whitelist()
private static final Safelist GODOC_ALLOWLIST = new Safelist()
.addTags("code", "pre", "ul", "ol", "li", "a", "br", "h1", "h2", "h3", "h4", "h5", "h6")
.addAttributes("a", "href")
.addProtocols("a", "href", "http", "https", "mailto");
Expand Down Expand Up @@ -69,7 +69,7 @@ public static String convert(String docs) {
String htmlDocs = HtmlRenderer.builder().escapeHtml(false).build().render(MARKDOWN_PARSER.parse(docs));

// Strip out tags and attributes we can't reasonably convert to godoc.
htmlDocs = Jsoup.clean(htmlDocs, GODOC_WHITELIST);
htmlDocs = Jsoup.clean(htmlDocs, GODOC_ALLOWLIST);

// Now we parse the html and visit the resultant nodes to render the godoc.
FormattingVisitor formatter = new FormattingVisitor();
Expand Down