Search code examples
javascriptjsonangularjsngsanitize

Urls with escaped double quotes at the end break ngSanitize


I'm using messages from Twitter in an Angular project. I'm using linky to present urls in tweets as clickable links. My problem is that when a double quote is used immediately after a url in a link, ngSanitize, which parses the urls, causes an error.

This message causes no problems:

"text":"RT @SPORTBILD: .@GaryLineker lobt das @DFB_Team in höchsten Tönen! Und er sagt: \"Dankeschön!\" Video: https://t.co/zwWWa7LpvD \n#SportBildAwa…"

This message causes an error:

"text":"RT @NUFC_1980_1994: \"@turnipheadpic: Quayside Market 1986 c/o Newcastle Libraries http://t.co/b8MueTjx9I\" #nufc #safc"

Error message:

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

As you can tell, the escaped double quote isn't being handled correctly by ngSanitize. It's considered part of the url, and parsing breaks down.

Does anybody know a solution to this problem?


Solution

  • Wasn't so hard in the end. I found the following git issue: Linky on emails breaks with double quote in 1.2.21

    So I just updated the packages, angular and angular-sanitize to 1.2.3, now the bug doesn't happen any more!