Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Consider allowing HTML in datatip markdown #99

Open
Gert-dev opened this issue Oct 18, 2017 · 9 comments
Open

Consider allowing HTML in datatip markdown #99

Gert-dev opened this issue Oct 18, 2017 · 9 comments

Comments

@Gert-dev
Copy link

Description

I noticed that markdown in datatips sanitizes out HTML. I can understand this, but would like to request the ability to disable this, perhaps in the datatip or MarkedString data itself.

The reason for this is, at least in PHP, docblock comments can intermingle markdown and HTML and one codebase may decide to use markdown whilst one of its dependencies may resort solely to HTML.

I see that datatips uses the marked library, which I am currently also using. It should already allow this by simply not requesting sanitization of the input value. (In the end, the embedded HTML is just more HTML to be displayed in the datatip after the markdown has been converted.)

Expected Behavior

HTML would not be sanitized or there would be an option to disable it for datatip markdown strings.

Actual Behavior

HTML is always sanitized in datatip markdown strings.

Versions

  • Atom: 1.21.0
  • Client OS: Linux
  • atom-ide-ui: 0.5.1
Gert-dev added a commit to Gert-dev/php-ide-serenata that referenced this issue Oct 18, 2017
Datatips are much like our original tooltips, but they have a way to
become sticky, after which the user can drag them anywhere he wants
and also scroll through them. This pretty much removes the need for
a separate dock.

It also makes our UI consistent with that of other IDE packages and
allows us to benefit from UI and functionality improvements done in
atom-ide-ui itself.

Finally, this code is pretty much ready for use, except there are some
minor nitpicks in atom-ide-ui that I'd like ironed out before pushing
this in php-integrator:

  - facebookarchive/atom-ide-ui#98
  - facebookarchive/atom-ide-ui#99

References #315
Gert-dev added a commit to Gert-dev/php-ide-serenata that referenced this issue Oct 19, 2017
This replaces our own implementation with the one from atom-ide-ui. Next
to having a consistent UI with other IDE packages and benefitting from
improvements made over there, they also offer several advantages over
our own implementation:

  - It is configured here to automatically trigger (!) when the
    paranthesis is typed. To add to that, it automatically remains open
    as long as the user continues typing and doesn't move outside the
    function call. This means it will never pop up automatically unless
    either typing a new function call or explicitly requesting it.
  - You can easily close it by pressing escape (#300) or moving outside
    of the function call, so it gets in the way much less often.
  - It also displays, next to the active parameter's documentation, the
    documentation of the function itself (mostly deals with #301).
  - It displays above the function call, so it doesn't overlap with
    autocompletion (#311)
  - You can drag them out of the way.
  - You can attach keyboard triggers to them.

Finally, this code is pretty much ready for use on our end, but there
are some minor issues I'd like to see ironed out in atom-ide-ui before
releasing this:

  - The API is currently still experimental
  - The styling is currently a bit barebones; the name of the active
    parameter is not displayed.
  - HTML in descriptions is being escaped (same issue as
    facebookarchive/atom-ide-ui#99)

References #300
References #301
References #311
@Arcanemagus
Copy link
Contributor

This is somewhat related to #45, as the ability to render HTML in the Markdown is needed for compatibility with Linter v2 providers.

@ricpelo
Copy link

ricpelo commented Jan 21, 2018

Any news or progress with this issue?

@Gert-dev
Copy link
Author

Gert-dev commented Jan 25, 2018

Even though this is probably still useful, I'm considering trying to convert HTML to markdown for my use case - as really HTML in PHP docblocks is very rare nowadays. Not ideal, but it might work (for others as well).

@hansonw
Copy link
Contributor

hansonw commented Jan 25, 2018 via email

@hansonw
Copy link
Contributor

hansonw commented Jan 26, 2018

Ah, I'm not sure how to do this. marked doesn't come with any builtin mechanism for basic HTML (related issues without answers: markedjs/marked#527, markedjs/marked#1037). The security consequences here aren't so severe but I'm still uncomfortable with the idea of allowing arbitrary JS in datatips... if there's a safe way of allowing basic HTML I'd be open to it.

@Gert-dev
Copy link
Author

Well, perhaps it is possible to let marked not touch the HTML and the running some kind of additional processing on the output to strip script tags? I think stripping script tags wouldn't be sufficient, as there are also other HTML attributes that can contain JavaScript.

Is there perhaps a way to activate a CSP for these inline scripts or evals or sandbox them?

Another idea would be to do the same I'm doing in my server now: convert HTML to markdown, but that comes with caveats of its own.

Yet another idea would be to either simply not allow plain HTML, it possible wouldn't be compatible with the linter API, but I guess security is more important than maintaining backwards compatibility, but that leaves other servers that do need this in the dark; I'm not sure if there are any servers that need this that aren't in a position to convert it themselves, though.

Finally, it could be hidden behind a switch to allow it via user settings, but it feels a bit like giving the user a shotgun to shoot himself in the foot: "Tick this checkbox to disable security and open everything up for unwanted scripts!".

@damieng
Copy link

damieng commented Jan 27, 2018 via email

@Gert-dev
Copy link
Author

That is very true.

I think there is one additional hole that opens up by not sanitizing script tags that propagate through the language server: the server might not care for it, but in my case, if I let HTML from PHP docblocks containing script tags propagate to Atom, theoretically any PHP dependency one uses in his or her project could use a script tag to try and exploit an Atom user as it would be injected into datatips or signature help.

@daviwil
Copy link

daviwil commented Jan 27, 2018

FWIW, VS Code escapes any HTML tags inside of the markdown text returned from a language server:

https://github.com/Microsoft/vscode/blob/c67ef57cda90b5f28499646f7cc94e8dcc5b0586/src/vs/base/common/htmlContent.ts#L11

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants