doulei2100 2015-06-26 01:37
浏览 158

jQuery只转义某些html实体

I have a little profile system with mentions in place

The 'content' value in my Posts table is stored as:

<a href="/profile/Alice">Alice</a> Alice, you there? &lt;strong&gt;lol&lt;/strong&gt;
  • the a href Profile link is generated by my system (I replace all mentions with a html link to the profile)
  • the <strong>lol</strong> are user-defined HTML that I do not wish to display (I use htmlentities() on all user-posts so their html input becomes that)

However, the end-result is everything being shown as HTML (I display them using json and jquery). How can I make it such that it only shows the in HTML (for my mention links), but not all the user-specified ones? (i.e. <strong>)

I want the post to display the mentions in hyper link, but at the same time, I do not want all user entered html to be displayed as html.

I use jQuery append to display my posts.

Thanks!

  • 写回答

2条回答 默认 最新

  • doutui6644 2015-06-26 01:40
    关注
    $str = '<a href="/profile/Alice">Alice</a> Alice, you there? &lt;strong&gt;lol&lt;/strong&gt;';
    $str = html_entity_decode($str);
    echo $str;
    exit;
    
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码