【问题标题】:Adobe AEM CQ XSS filterAdobe AEM CQ XSS 过滤器
【发布时间】:2016-01-08 19:56:06
【问题描述】:

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

我的语法不正确吗?

【问题讨论】:

    标签: content-management-system adobe aem


    【解决方案1】:

    这是因为您正在使用 OOTB 文本组件,而 OOTB 文本组件使用&lt;cq:text&gt; 标签来显示组件中配置的文本。类似于下图。

    &lt;cq:text property="text" escapeXml="true" ... /&gt;

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

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

    【讨论】:

    • 谢谢,这对我的研究有帮助。请参阅我上面的更新说明。
    猜你喜欢
    • 1970-01-01
    • 2014-10-22
    • 2014-07-24
    • 2018-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多