Adobe AEM CQ XSS过滤器

时间:2016-01-08 19:56:07

标签: content-management-system adobe cq5

在我的作者中,我正在编辑文本组件并添加以下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>

我的语法是否正确?

1 个答案:

答案 0 :(得分:0)

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

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

在幕后,当escapeXml属性设置为true时,它在内部调用XSSAPI的#filterHTML方法,其输出剥离了所有数据属性。

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

相关问题