duckduckgo/zeroclickinfo-fathead

GitManual: "<>" are not escaped properly

Closed this issue · 3 comments

nheir commented

Description

Characters "<" and ">" should be escaped not to be confuse with html tags :
For instance in

git branch [--color[=<when>] | --no-color] [-r | -a]\n [--list] [-v [--abbrev=<length> | --no-abbrev]]\n [--column[=<options>] | --no-column]\n [(--merged | --no-merged | --contains) [<commit>]] [--sort=<key>]\n [--points-at <object>] [<pattern>\u2026\u200b]\ngit branch [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]\ngit branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]\ngit branch --unset-upstream [<branchname>]\ngit branch (-m | -M) [<oldbranch>] <newbranch>\ngit branch (-d | -D) [-r] <branchname>\u2026\u200b\ngit branch --edit-description [<branchname>]"

<options>, <color> etc are not shown in https://beta.duckduckgo.com/?q=gitbranch
And this breaks the whole html layout (at least on Firefox 66) https://beta.duckduckgo.com/html/?q=gitbranch

Steps to recreate

Open one of those links :


Instant Answer Page: https://duck.co/ia/view/git_manual

@nheir thanks for reporting.

The missing <when>, <length> etc, might be due to the syntax highlighter. I see them in the JSON response we pass to the frontend: https://duckduckgo.com/?q=git+am&t=ffab&ia=web&o=json

The /html breakage is due to the html site's handling of the Fathead data -- it wasn't expecting it to contain HTML tags. We'll be fixing this internally.

DuckDuckHack is currently in maintenance mode though and we're only accepting critical bug reports. I'm not sure this rises to that level so we will have to tolerate this for now.

nheir commented

the json answer also contains valid (and expected) html tags like <section> or <pre>.

See

PEP 341 A <section class="prog__container">\n<span class="prog__sub">Title</span>\n<p>PEP 341 - Unifying try-except and try-finally</p>\n<span class="prog__sub">Description</span>\n<p>This PEP proposes a change in the syntax and semantics of try\nstatements to allow combined try-except-finally blocks. This\nmeans in short that it would be valid to write:\n </p>\n<pre><code>\ntry:\n &lt;do something&gt;\nexcept Exception:\n &lt;handle the error&gt;\nfinally:\n &lt;cleanup&gt;\n</code></pre>\n</p>\n</section> https://www.python.org/dev/peps/pep-0341/

using &lt;do something&gt;

vs

git-add A <section class="prog__container"><p>Add file contents to the index</p>\n<pre><code>git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]\n [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]\n [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing]\n [--chmod=(+|-)x] [--] [<pathspec>…​]</code></pre></section> https://git-scm.com/docs/download\add.html

using raw <pathspec>

@nheir good catch looks like they need to be escaped by the parser. Given maintenance mode I don't think we're going to fix this.