kylehuff/webpg-chrome

Cannot decrypt! (Need better handling PGP messages in poorly formatted HTML)

Closed this issue · 3 comments

Maybe I am just wrong but in my case (latest chrome on Linux) I cannot decrypt a message because right clicking on the text and going to "WebPG" just gives me "Options" and "Key Manager". I first have to copy the text, paste it in some textarea on the page and after that I can right click chose "WebPG" -> "Decrypt". That's a bit complicated.

@ddidderr is this text that is in, for example, an HTML element as opposed to being inside of an input element?

Text within HTML is not (yet) able to be decrypted/verified from the right-click context menu, however, the option "Enable Inline formatting of PGP Messages and Keys" within the options page for webpg-chrome should transform blocks of PGP data found on a page with an interactive element, that permits decryption/verification.

@kylehuff yes it is inside an non-input HTML element.

I tried "Enable Inline formatting of PGP Messages and Keys" but unfortunately it says it cannot decrypt the message. If I disable the option and do it by hand it works. If I copy the message using the button and paste it somewhere I see a <br> at the end of each line of the encrypted text.

Yes, unfortunately, whoever put that information into the HTML element didn't do it correctly. PGP data requires that the message preserve the formatting (linebreaks, most notably) - so it should really be put into an HTML element, by itself without any other HTML tags (such as br, wbr, etc) and the parent tag should be a pre tag, or equivalent.

The next version of WebPG will handle these kinds of situations (slightly) better, but the extension can't just go around removing valid HTML from within PGP blocks, since a valid signed message may very well include HTML tags, and removing the tags would cause the signature to fail.

I hate to push this off on the provider of the data, but I believe that really is the root issue here. I am going to change the title of the this issue to something that better reflects what needs to be done, and I the next time I push code that touches on this topic, you should get notified.