【问题标题】:Urls with escaped double quotes at the end break ngSanitize最后带有转义双引号的 URL 会破坏 ngSanitize
【发布时间】:2014-08-26 12:08:59
【问题描述】:

我在一个 Angular 项目中使用来自 Twitter 的消息。我正在使用 linky 将推文中的网址显示为可点击的链接。我的问题是,当链接中的 url 后立即使用双引号时,解析 url 的 ngSanitize 会导致错误。

此消息不会导致任何问题:

"text":"RT @SPORTBILD: .@GaryLineker lobt das @DFB_Team in höchsten 东宁!在 er sagt 下:\"Dankeschön!\" 视频:https://t.co/zwWWa7LpvD \n#SportBildAwa..."

此消息导致错误:

"text":"RT @NUFC_1980_1994: \"@turnipheadpic: Quayside Market 1986 c/o 纽卡斯尔图书馆http://t.co/b8MueTjx9I\"#nufc #safc"

错误信息:

Error: [$sanitize:badparse] The sanitizer was unable to parse the
following block of html: <a target="_blank"
href="http://t.co/b8MueTjx9I"">http://t.co/b8MueTjx9I&#34;</a> #nufc
#safc

如您所知,ngSanitize 没有正确处理转义的双引号。它被认为是 url 的一部分,解析失败。

有人知道这个问题的解决方案吗?

【问题讨论】:

    标签: javascript json angularjs ngsanitize


    【解决方案1】:

    最后也没那么难。我发现了以下 git 问题:Linky on emails breaks with double quote in 1.2.21

    所以我刚刚将包 angular 和 angular-sanitize 更新到 1.2.3,现在该错误不再发生了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      • 2013-01-17
      • 1970-01-01
      • 1970-01-01
      • 2020-11-26
      • 1970-01-01
      • 2015-12-02
      相关资源
      最近更新 更多