给客户做的网站,用 thinkcmf 做的 cms 系统,里面文章里面需要触发 mailto
的功能,狗日的最后渲染出来的地址乱七八糟,加了两层 http .
研究了下,问题有两个:
- ueditor 自身处理的时候,会自动增加 http 前缀.不知道图啥.
代码位置:
public/static/js/ueditor/dialogs/link/link.html
大约90行左右,增加mailto
的条件.
if (!hrefStartWith(href, [“http”, “/”, “ftp://”, ‘#’, ‘mailto’])) {
href = “http://” + href;
}
不过值得提一下,可能是版本问题,ueditor 的 config 文件中,allowLinkProtocols
里面其实有mailto
的,但是并没有什么卵用??
这个问题处理过了,发现还有一层.
2.是 thinkcmf
的问题.
渲染 html 内容的时候,会调用:
simplewind/cmf/common.php
的 1601行左右 cmf_replace_content_file_url()
方法:
1650行 我改成了:
if (preg_match(“/^mailto/”, $href)) {
$link->attr(“href”, $href);
}else{
if (!(preg_match(“/^\//”, $href) || preg_match(“/^http/”, $href))) {
$link->attr(“href”, cmf_get_file_download_url($href));
}
}
不再处理这个 href.
然后清理下 thinkcmf
的缓存,前端强制刷新下.
问题解决.
网友评论