繁体   English   中英

Adobe AEM CQ XSS过滤器

[英]Adobe AEM CQ XSS filter

在我的作者中,我正在编辑文本组件并添加以下html:

<li><span><a href="#" class="tt" data-toggle="popover" data-html="true" data-placement="top" data-content="Test text" role="button">test text</a></span></li>

但是,当我切换到预览模式时,呈现的html是:

<li><span><a class="tt" href="#">Test text</a></span></li>

看来AEM正在剥离某些属性。 有什么想法吗?

更多信息经过更多阅读之后,我认为我将其范围缩小到将属性添加到/libs/cq/xssprotection/config.xml。 但是,添加以下代码后,页面将停止加载:

    <tag name="div" action="validate">
        <attribute name="align"/>
        <attribute name="data-toggle">
            <regexp-list>
                <regexp name="data-toggle"/>
            </regexp-list>
        </attribute>
        <attribute name="data-html">
            <regexp-list>
                <regexp name="data-html"/>
            </regexp-list>
        </attribute>
        <attribute name="data-placement">
            <regexp-list>
                <regexp name="data-placement"/>
            </regexp-list>
        </attribute>
        <attribute name="data-content">
            <regexp-list>
                <regexp name="data-content"/>
            </regexp-list>
        </attribute>
    </tag>

我的语法不正确吗?

这是因为您使用的是OOTB文本组件,而OOTB文本组件使用<cq:text>标记来显示在组件中配置的文本。 与下面显示的类似。

<cq:text property="text" escapeXml="true" ... />

在后台,将escapeXml属性设置为true时,它将在内部调用XSSAPI的#filterHTML方法,该方法的输出将删除所有数据属性。

您可以覆盖文本组件,并在需要时删除escapeXml属性,或者根据要求在覆盖后实现逻辑。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM