【发布时间】: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"</a> #nufc
#safc
如您所知,ngSanitize 没有正确处理转义的双引号。它被认为是 url 的一部分,解析失败。
有人知道这个问题的解决方案吗?
【问题讨论】:
标签: javascript json angularjs ngsanitize