mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move owasp back to the markdown
This commit is contained in:
Generated
-12
@@ -1,12 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1" type="repository">
|
||||
<properties maven-id="com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/owasp-java-html-sanitizer/owasp-java-html-sanitizer/20180219.1/owasp-java-html-sanitizer-20180219.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/owasp-java-html-sanitizer/owasp-java-html-sanitizer/20180219.1/owasp-java-html-sanitizer-20180219.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -15,6 +15,5 @@
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.spellchecker" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
|
||||
<orderEntry type="library" name="com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,52 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.rest.editor;
|
||||
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.owasp.html.HtmlPolicyBuilder;
|
||||
import org.owasp.html.PolicyFactory;
|
||||
import org.owasp.html.Sanitizers;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
|
||||
public class RestSwingHtmlPanel implements RestPreviewPanel {
|
||||
|
||||
final static NotNullLazyValue<PolicyFactory> SANITIZER_VALUE = new NotNullLazyValue<PolicyFactory>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected PolicyFactory compute() {
|
||||
return Sanitizers.BLOCKS
|
||||
.and(Sanitizers.FORMATTING)
|
||||
.and(new HtmlPolicyBuilder()
|
||||
.allowUrlProtocols("file", "http", "https").allowElements("img")
|
||||
.allowAttributes("alt", "src", "title").onElements("img")
|
||||
.allowAttributes("border", "height", "width").onElements("img")
|
||||
.toFactory())
|
||||
.and(new HtmlPolicyBuilder()
|
||||
.allowUrlProtocols("file", "http", "https", "mailto").allowElements("a")
|
||||
.allowAttributes("href", "title").onElements("a")
|
||||
.toFactory())
|
||||
.and(new HtmlPolicyBuilder()
|
||||
.allowStandardUrlProtocols()
|
||||
.allowElements("table", "tr", "td", "th", "caption", "thead", "tbody", "tfoot")
|
||||
.allowAttributes("summary").onElements("table")
|
||||
.allowAttributes("align", "valign")
|
||||
.onElements("table", "tr", "td", "th", "thead", "tbody", "tfoot")
|
||||
.allowTextIn("table")
|
||||
.toFactory())
|
||||
.and(new HtmlPolicyBuilder()
|
||||
.allowStandardUrlProtocols()
|
||||
.allowElements("pre", "span")
|
||||
.toFactory())
|
||||
.and(new HtmlPolicyBuilder()
|
||||
.allowElements("code", "tr")
|
||||
.allowAttributes("class").onElements("code", "tr")
|
||||
.toFactory());
|
||||
}
|
||||
};
|
||||
|
||||
private final JTextPane myPane;
|
||||
private final JScrollPane myScrollPane;
|
||||
|
||||
@@ -58,7 +20,6 @@ public class RestSwingHtmlPanel implements RestPreviewPanel {
|
||||
|
||||
@Override
|
||||
public void setHtml(@NotNull String html) {
|
||||
html = "<html>" + SANITIZER_VALUE.getValue().sanitize(html) + "</html>";
|
||||
myPane.setText(html);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user