duckduckgo / zeroclickinfo-spice

DuckDuckGo Instant Answers based on JavaScript (JSON) APIs
https://duckduckhack.com/
Other
548 stars 942 forks source link

Bible: HTML encoding in API response #2055

Closed cotto closed 9 years ago

cotto commented 9 years ago

The instant answer for hosea 11:9 shows some mojobake:

I cannot carry out my fierce anger! I cannot totally destroy Ephraim! Because I am God, and not man – the Holy One among you – I will not come in wrath!


IA Page: http://duck.co/ia/view/bible

jagtalon commented 9 years ago

Thanks! We get those entities rendering properly.

cotto commented 9 years ago

Yeah. That was github being helpful. Here's a screenshot in Chrome 43.0.2357.134 on Windows. I saw the same thing in Firefox nightly on Linux. untitled

MrChrisW commented 9 years ago

@cotto Thanks for reporting this.

Issue The API is returning HTML entities

See: https://duckduckgo.com/js/spice/bible/hosea%2011%3A9

Fix: Use stripHTML in handlebars template

Notes This API should moved away from the base template group: https://github.com/duckduckgo/zeroclickinfo-spice/blob/ed05efa4152f627dd3e54821bca2eb563d105192/share/spice/bible/bible.js#L22

iambibhas commented 9 years ago

@MrChrisW #stripHTML doesn't work. Handlebars can't decode HTML entities. Have to do it in JS, something like this -

var text = $('<textarea />').html(data.text).text();
MrChrisW commented 9 years ago

@iambibhas That's correct :+1: Thanks for the clarification. In reality the API shouldn't be passing HTML entities.