duckduckgo / zeroclickinfo-goodies

DuckDuckGo Instant Answers based on Perl & JavaScript
https://duckduckhack.com/
Other
979 stars 1.76k forks source link

FlipText: Non-ASCII characters get escaped so they look weird #1099

Closed jagtalon closed 8 years ago

jagtalon commented 9 years ago

screen shot 2015-04-09 at 10 55 42 am

Query: "flip text /sɹoqɥƃıǝu‾sɹıɐʇsdn‾sǝuoʎɹǝʌǝ/4ɥʍʍ⇂Ɛ/sʇuǝɯɯoɔ/soǝpıʌ/ɹ/ɯoɔ˙ʇıppǝɹ˙ʍʍʍ//:dʇʇɥ"

moollaza commented 9 years ago

@jagtalon I believe this is requires an internal fix? We should probably update our template to not escape the contents and make sure we HTML encode the input internally so dev's don't have to worry.

jagtalon commented 9 years ago

@moollaza cool--will see what I can do on our end.

zachthompson commented 9 years ago

Just a quick test in duckpan shows that, within the goodie, the values are the same regardless of whether the query was upside down or not:

input: http://duckduckgo.com/?q=result
result: ʇʃnsǝɹ=b¿/ɯoɔ˙oƃʞɔnpʞɔnp//:dʇʇɥ
input_enc: http://duckduckgo.com/?q=result
result enc: ʇʃnsǝɹ=b¿/ɯoɔ˙oƃʞɔnpʞɔnp//:dʇʇɥ

input: ʇʃnsǝɹ=b¿/ɯoɔ˙oƃʞɔnpʞɔnp//:dʇʇɥ
result: http://duckduckgo.com/?q=result
input_enc: ʇʃnsǝɹ=b¿/ɯoɔ˙oƃʞɔnpʞɔnp//:dʇʇɥ
result enc: http://duckduckgo.com/?q=result

Particularly look at the encoded versions of the upside down text which are the same. Somewhere we are already encoding the input by default. So this only shows up where html_enc actually does something and it encodes twice.

Removing html_enc on the input fixes this.

reverse text ʇʃnsǝɹ=b¿/ɯoɔ˙oƃʞɔnpʞɔnp//:dʇʇɥ <--- whoa

zachthompson commented 9 years ago

@moollaza we also saw this with Mönchengladbach as input when looking at the utf8 stuff.