"tel"属性在AEM 6.1经典UI的富文本编辑器中的锚标记的href中不起作用



我正在使用AEM 6.1 SP2,我正在尝试在锚标记的href中启用"tel"属性以使单击调用功能正常工作。我已经添加了"htmlRules"节点 并在 htmlRules 节点下链接节点,其中"协议"属性为 [http://, https://, ftp://, tel:, mailto:, file://]

如链接中所述 - http://labs.6dglobal.com/blog/2013-01-11/configuring-telephone-tags-within-rich-text-components-and-link-checker/

rte.js中的"validateHref"函数确实读取了"协议"属性并验证"tel"属性是否有效,但不确定为什么在作者对话框中单击"ok"时"tel"属性不会保留在标记中。

这是锚标签 -

<a style="color: #6c6c6c; text-decoration: underline;" class="tel" href="tel:1234 567 891">1234 567 89</a>

这就是它在页面上呈现为标记的方式 -

<a style="color: rgb(108,108,108);text-decoration: underline;" class="tel">1234 567 89</a>

这是 'htmlRules' 节点 xml -

<htmlRules jcr:primaryType="nt:unstructured">
<serializer jcr:primaryType="nt:unstructured">
<cleanup jcr:primaryType="nt:unstructured">
<pre
jcr:primaryType="nt:unstructured"
tagsToRemove="[]"/>
<post
jcr:primaryType="nt:unstructured"
tagsToRemove="[]"/>
<paste
jcr:primaryType="nt:unstructured"
tagsToRemove="[]"/>
</cleanup>
</serializer>
<links
jcr:primaryType="nt:unstructured"
protocols="[http://,https://,ftp://,tel:,mailto:,file://]"/>
</htmlRules>

这是修复的,覆盖了 xssprotection 配置文件 -

/libs/cq/xssprotection/config.xml

/apps/cq/xssprotection/config.xml

并在正则表达式列表中添加"tel"属性

<regexp name="telURL" value="tel:[0-9]+"/>
<attribute name="href">
<regexp-list>
<regexp name="onsiteURL"/>
<regexp name="offsiteURL"/>
<regexp name="telURL"/>
</regexp-list>
</attribute>

这已在博客中描述过:

https://experience-aem.blogspot.com.au/2015/05/aem-6-sp2-handling-custom-protocol-in-link-href-in-rte.html

尽管在该博客和其他地方都提到了它

基于富文本构件的输入在 HTL 中呈现电话链接

https://forums.adobe.com/thread/2329552

为了美观起见,配置文件位于 -

/libs/sling/xss/config.xml

而不是在

/libs/cq/xssprotection/config.xml

即使我使用美观的组件,

/libs/wcm/foundation/components/text/text.html

即便如此,在/libs/sling/xss/config.xml 上覆盖配置文件也没有任何效果,我不得不在/libs/cq/xssprotection/config.xml 覆盖该文件。我正在使用AEM 6.1 SP2。AEM的神秘方式

我们已经按照您共享的参考链接做了相同的操作,但我们正在从对话框中传递"href"值。 ex href="tel: ${properties.propertyname}". 或者你可以尝试像href="${properties.propertyname}"并从对话框"tel:123456789"传递值。 不确定这是否会对您有所帮助。 谢谢。

您在问题中链接的解决方案似乎不适用于最新版本的AEM。

现在负责删除hreftel开始的机制是 HTL XSS 保护,它在写入属性之前扫描属性。避免这种情况的最简单方法是在富文本组件中禁用它:${properties.text @ context='unsafe'}。这不是最安全的解决方案,相反,最好通过以下步骤扩展XSS保护配置:

通过将XSS配置文件
  1. 从库复制到应用程序来覆盖XSS配置文件:

/libs/cq/xssprotection/config.xml->/apps/cq/xssprotection/config.xml/libs/sling/xss/config.xml->/apps/sling/xss/config.xml

  1. 添加带有新正则表达式的协议:

<regexp name="telURL" value="tel:[0-9]+"/>

  1. telURL添加到锚点href属性的regexp-list

<regexp name="telURL"/>

    执行
  1. 这些更改后,可能还需要重新启动AEM实例。

如果出现问题,您可以在此博客页面和此Stackoverflow文章中阅读有关它的更多信息。

此外,链接检查器机制可能仍会在编辑模式下将您的链接标记为无效,并且在发布时可以将其删除。

根据是否需要它使其适用于应用中的一个或所有特定定位点或所有定位点,你可以:

  • x-cq-linkchecker="skip"属性添加到您的锚点,i.net 帖子下的评论中所建议的那样
  • 或者,如果您希望允许将tel添加到页面上的任何可能的锚点,请在Day CQ链接检查器服务OSGI服务中添加例外tel:特殊链接前缀。请注意,此时需要将服务配置应用于所有创作和发布实例。

最新更新