本文整理了Java中org.jsoup.safety.Whitelist.relaxed()
方法的一些代码示例,展示了Whitelist.relaxed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Whitelist.relaxed()
方法的具体详情如下:
包路径:org.jsoup.safety.Whitelist
类名称:Whitelist
方法名:relaxed
[英]This whitelist allows a full range of text and structural body HTML: a, b, blockquote, br, caption, cite, code, col, colgroup, dd, div, dl, dt, em, h1, h2, h3, h4, h5, h6, i, img, li, ol, p, pre, q, small, span, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, u, ul
Links do not have an enforced rel=nofollow
attribute, but you can add that if desired.
[中]此白名单允许完整的文本和结构体HTML:a, b, blockquote, br, caption, cite, code, col, colgroup, dd, div, dl, dt, em, h1, h2, h3, h4, h5, h6, i, img, li, ol, p, pre, q, small, span, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, u, ul
链接没有强制的rel=nofollow
属性,但如果需要,可以添加该属性。
代码示例来源:origin: k9mail/k-9
HtmlSanitizer() {
Whitelist whitelist = Whitelist.relaxed()
.addTags("font", "hr", "ins", "del", "center", "map", "area")
.addAttributes("font", "color", "face", "size")
.addAttributes("table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing",
"width")
.addAttributes("tr", "align", "background", "bgcolor", "valign")
.addAttributes("th",
"align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
"sorted", "valign", "width")
.addAttributes("td",
"align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
"valign", "width")
.addAttributes("map", "name")
.addAttributes("area", "shape", "coords", "href", "alt")
.addProtocols("area", "href", "http", "https")
.addAttributes("img", "usemap")
.addAttributes(":all", "class", "style", "id", "dir")
.addProtocols("img", "src", "http", "https", "cid", "data")
.addProtocols("a", "href", "tel", "sip", "bitcoin", "ethereum", "rtsp");
cleaner = new Cleaner(whitelist);
headCleaner = new HeadCleaner();
}
代码示例来源:origin: tomoya92/pybbs
content = Jsoup.clean(content, Whitelist.relaxed().addTags("code", "pre").addAttributes("code", "class"));
Document parse = Jsoup.parse(content);
Elements tableElements = parse.select("table");
代码示例来源:origin: ron190/jsql-injection
.replaceAll("<input.*type=\"?(submit|button)\"?.*>", "<div style=\"background-color:#eeeeee;text-align:center;border:1px solid black;width:100px;\">button</div>")
.replaceAll("<input.*>", "<div style=\"text-align:center;border:1px solid black;width:100px;\">input</div>"),
Whitelist.relaxed()
.addTags("center", "div", "span")
.addAttributes(":all", "style")
代码示例来源:origin: ron190/jsql-injection
.replaceAll("<input.*type=\"?(submit|button)\"?.*>", "<div style=\"background-color:#eeeeee;text-align:center;border:1px solid black;width:100px;\">button</div>")
.replaceAll("<input.*>", "<div style=\"text-align:center;border:1px solid black;width:100px;\">input</div>"),
Whitelist.relaxed()
.addTags("center", "div", "span")
.addAttributes(":all", "style")
代码示例来源:origin: viritin/viritin
public Whitelist getWhitelist() {
if (whitelist == null) {
return Whitelist.relaxed();
}
return whitelist;
}
代码示例来源:origin: viritin/viritin
public Whitelist getWhitelist() {
if (whitelist == null) {
return Whitelist.relaxed();
}
return whitelist;
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-workflow-sharing-plugin
public String asMarkdown()
{
return Jsoup.clean(markdown, Whitelist.relaxed());
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-workflow-sharing-plugin
public String getNotesAsMarkdown()
{
String md = "";
if(null != notes && notes.exists())
{
try
{
md = FileUtils.readFileToString(notes);
}
catch (IOException e)
{
md = "";
}
}
String safeMD = Jsoup.clean(md, Whitelist.relaxed());
return safeMD;
}
代码示例来源:origin: ZapBlasterson/crushpaper
@Override
protected Whitelist initialValue() {
return Whitelist.relaxed()
.addEnforcedAttribute("a", "rel", "nofollow")
.addEnforcedAttribute("a", "target", "_blank");
}
};
代码示例来源:origin: com.atlassian.jira.plugins/jira-workflow-sharing-plugin
public String asHtml()
{
return Jsoup.clean(pegDown.markdownToHtml(markdown),Whitelist.relaxed());
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-workflow-sharing-plugin
public String getNotesAsHtml()
{
String html = "";
if(null != notes && notes.exists())
{
try
{
String md = FileUtils.readFileToString(notes);
html = pegDown.markdownToHtml(md);
}
catch (IOException e)
{
html = "";
}
}
String safeHtml = Jsoup.clean(html, Whitelist.relaxed());
return safeHtml;
}
}
代码示例来源:origin: roncoo/roncoo-recharge
@Override
public String[] getParameterValues(String name) {
String[] values = super.getParameterValues(name);
if (values != null) {
int length = values.length;
String[] escapseValues = new String[length];
for (int i = 0; i < length; i++) {
// 防xss攻击和过滤前后空格
escapseValues[i] = Jsoup.clean(values[i], Whitelist.relaxed()).trim();
}
return escapseValues;
}
return super.getParameterValues(name);
}
}
代码示例来源:origin: lerry903/RuoYi
@Override
public String[] getParameterValues(String name) {
String[] values = super.getParameterValues(name);
if (values != null) {
int length = values.length;
String[] escapseValues = new String[length];
for (int i = 0; i < length; i++) {
// 防xss攻击和过滤前后空格
escapseValues[i] = Jsoup.clean(values[i], Whitelist.relaxed()).trim();
}
return escapseValues;
}
return super.getParameterValues(name);
}
}
代码示例来源:origin: org.apache.myfaces.tobago/tobago-core
@Override
public void setProperties(final Properties configuration) {
checkLocked();
unmodifiable = true;
for (final String key : configuration.stringPropertyNames()) {
if ("whitelist".equals(key)) {
whitelistName = configuration.getProperty(key);
if ("basic".equals(whitelistName)) {
whitelist = Whitelist.basic();
} else if ("basicWithImages".equals(whitelistName)) {
whitelist = Whitelist.basicWithImages();
} else if ("none".equals(whitelistName)) {
whitelist = Whitelist.none();
} else if ("relaxed".equals(whitelistName)) {
whitelist = Whitelist.relaxed();
} else if ("simpleText".equals(whitelistName)) {
whitelist = Whitelist.simpleText();
} else {
throw new TobagoConfigurationException(
"Unknown configuration value for 'whitelist' in tobago-config.xml found! value='" + whitelistName + "'");
}
} else {
throw new TobagoConfigurationException(
"Unknown configuration key in tobago-config.xml found! key='" + key + "'");
}
}
if (LOG.isInfoEnabled()) {
LOG.warn("Using whitelist '" + whitelistName + "' for sanitizing!");
}
}
代码示例来源:origin: lucene4ir/lucene4ir
public TRECAquaintDocumentIndexer(String indexPath, String tokenFilterFile, boolean positional){
super(indexPath, tokenFilterFile, positional);
try {
whiteList = Whitelist.relaxed();
whiteList.addTags("docno");
whiteList.addTags("doc");
whiteList.addTags("headline");
whiteList.addTags("text");
whiteList.addTags("date_time");
whiteList.addTags("slug");
} catch (Exception e){
System.out.println(" caught a " + e.getClass() +
"\n with message: " + e.getMessage());
}
doc = new Document();
initFields();
initAQUAINTDoc();
}
代码示例来源:origin: pnikosis/jHTML2Md
private static String parseDocument(Document dirtyDoc) {
indentation = -1;
String title = dirtyDoc.title();
Whitelist whitelist = Whitelist.relaxed();
Cleaner cleaner = new Cleaner(whitelist);
Document doc = cleaner.clean(dirtyDoc);
doc.outputSettings().escapeMode(EscapeMode.xhtml);
if (!title.trim().equals("")) {
return "# " + title + "\n\n" + getTextContent(doc);
} else {
return getTextContent(doc);
}
}
代码示例来源:origin: br.com.anteros/Anteros-Bean-Validation
public void initialize(SafeHtml safeHtmlAnnotation) {
switch ( safeHtmlAnnotation.whitelistType() ) {
case BASIC:
whitelist = Whitelist.basic();
break;
case BASIC_WITH_IMAGES:
whitelist = Whitelist.basicWithImages();
break;
case NONE:
whitelist = Whitelist.none();
break;
case RELAXED:
whitelist = Whitelist.relaxed();
break;
case SIMPLE_TEXT:
whitelist = Whitelist.simpleText();
break;
}
whitelist.addTags( safeHtmlAnnotation.additionalTags() );
for ( SafeHtml.Tag tag : safeHtmlAnnotation.additionalTagsWithAttributes() ) {
whitelist.addAttributes( tag.name(), tag.attributes() );
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.hibernate-validator
@Override
public void initialize(SafeHtml safeHtmlAnnotation) {
switch ( safeHtmlAnnotation.whitelistType() ) {
case BASIC:
whitelist = Whitelist.basic();
break;
case BASIC_WITH_IMAGES:
whitelist = Whitelist.basicWithImages();
break;
case NONE:
whitelist = Whitelist.none();
break;
case RELAXED:
whitelist = Whitelist.relaxed();
break;
case SIMPLE_TEXT:
whitelist = Whitelist.simpleText();
break;
}
whitelist.addTags( safeHtmlAnnotation.additionalTags() );
for ( SafeHtml.Tag tag : safeHtmlAnnotation.additionalTagsWithAttributes() ) {
whitelist.addAttributes( tag.name(), tag.attributes() );
}
}
代码示例来源:origin: org.hibernate.validator/hibernate-validator
break;
case RELAXED:
whitelist = Whitelist.relaxed();
break;
case SIMPLE_TEXT:
内容来源于网络,如有侵权,请联系作者删除!