tejado / obsidian-gpgCrypt

Seamlessly encrypts your notes using GPG. Supports smartcards for enhanced security! 🔒📝📎
MIT License
38 stars 6 forks source link

[Question / Bug]: Cancelling GPG passphrase freezes page #6

Closed Aetherinox closed 11 months ago

Aetherinox commented 1 year ago

Hey,

I'm not sure if this is a bug, or unavoidable behavior by GPG, but it definitely has something to do with Obsidian.

A few days ago I created a note, test.md. I had opted in the settings for a note to be .gpg instead of .md, so test.md became test.gpg.

I let that note sit for a few days and decided to mess around with this plugin today, and just for testing purposes, I wanted to see what would happen if I clicked on the note to open it, but then cancelled the GPG prompt to enter my passphrase.

Once I clicked cancel, Obsidian will not allow me to click on any other note at all. All it does is just bring up a Obsidian notification which is the typical GPG error about cancelling the operation.

It will let me re-click on the note I originally tried to open and it prompts me for my passphrase again, but clicking cancel starts to loop all over. I can't click on any other note to open it until I actually click on that note and enter the passphrase.

Keeping in mind that the note I clicked cancel on is the only note in the vault encrypted. The rest are not and are just standard .md files.

I can however, open a new tab and start navigating around again, but I'd have to close the original tab because it's now useless unless I actually enter that passphrase.

Once I enter the passphrase for that file, all the pages work as normal.

tejado commented 1 year ago

Hi @Aetherinox thanks for creating the issue. I have not observed this behavior so far. May I ask what other plugins you are using and which Obsidian version?

Aetherinox commented 1 year ago

I'll have to run some tests today and see if plugins matter. Normally I turn this off but holidays has been busy

SYSTEM INFO:
    Obsidian version: v1.4.16
    Installer version: v1.1.16
    Operating system: Windows 10 Pro 10.0.22621
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: dark
    Community theme: Blue Topaz v2023101401
    Snippets enabled: 2
    Restricted mode: off
    Plugins installed: 45
    Plugins enabled: 40
        1: Code Styler v1.0.11
        2: Link Favicons v1.8.3
        3: Style Settings v1.0.7
        4: File Color v1.0.3
        5: Obsidian42 - BRAT v0.7.1
        6: Iconize v2.8.0
        7: Folder notes v1.6.11
        8: Advanced Tables v0.19.1
        9: Banners v2.0.5-beta
        10: Bartender v0.5.9
        11: Buttons v0.4.19
        12: Code Files v1.1.5
        13: Console Markdown Plugin v1.0.2
        14: Custom Frames v2.4.6
        15: Dataview v0.5.64
        16: Execute Code v1.9.0
        17: Front Matter Title v3.7.1
        18: Gist v0.9.1
        19: Image Converter v1.1.7
        20: Link Embed v2.0.10
        21: Meld Encrypt v2.3.5
        22: Reveal Active File Button v2.0.3
        23: Reveal file in explorer v1.5.6
        24: Spoiler Block v1.0.0
        25: Update modified date v1.3.2
        26: URL Display v1.3.0
        27: Vault Statistics v0.1.3
        28: Plugin Update Tracker v1.5.2
        29: Avatar v1.0.5
        30: gpgCrypt v0.2.0
        31: GitHub Embeds v1.0.3
        32: Editor Syntax Highlight v0.1.3
        33: Nomnoml Diagram v1.2.0
        34: Short links v1.1.5
        35: File Include v1.1.1
        36: Novel word count v2.25.2
        37: Admonition v10.1.1
        38: Meta Bind Plugin v0.8.0
        39: Inline Encrypter v1.1.0
        40: Open Gate v1.9.4

Oh and I forgot to mention, I'm using GnuPG wrapper, not OpenPGP.

Aetherinox commented 1 year ago

Looks like this is going to be one of those elusive things. I just created a new vault, installed the same theme, all the same plugins.

Encrypted a file, and made sure it was labeled "file.gpg" instead of .md. And it gives me the "cancelled operation" and then lets me continue fine.

But it still breaks on my original vault if I cancel.

The only thing extra I notice is when I am on a normal file, the tab has the filename as it should. When I click on the encrypted note to open it and then click cancel, the tab's name changes to "Code Editor". And then that tab is stuck from that point forward unless I actually decrypt the note.

Yet the other vault is fine. Makes no sense.

Aetherinox commented 1 year ago

I found the issue. I doubt you'll need to fix anything, or if you need to place a warning somewhere in the documentation. The issue has to do with the plugin https://github.com/lukasbach/obsidian-code-files

If you install the Code Files Plugin, there's a setting in there to add additional files you can open as code files V59kc6r

I had GPG added to that list because I was opening GPG files. And that conflicts with GPG Crypt.

So what's happening is it's attempting to have your plugin utilize GPG and decrypt the .gpg file, however, the Code Files plugin is trying to open the gpg file as a Code File, which basically just adds syntax highlighting / line numbers, so the tab isn't loading and it freezes.


There's two behaviors:

Option 1 (To replicate the freeze)

The tab will become stuck


Option 2 (Causes Code Files plugin to error out)

9W8o3jz

The tab will not get stuck. It has something to do with the order in which you install gpgCrypt and Code Files. If gpgCrypt is installed first, it has "priority[?]". And then Code Files plugin will be unable to register the .gpg extension.


So pretty much it's a conflict between The Code Files Plugin, and it trying to open it as a Code File, and then gpgCrypt trying to open it as a regular file.

If the .gpg extension gets removed from the Code Files plugin and then give the Obsidian vault a reboot, it then cancels fine and the tab doesn't get stuck anymore.

Obviously I doubt there's anything you can do, because adding GPG to the Code Files list makes no sense when you're using GPG as the extension for actually viewing encrypted notes. I had that .gpg file added to the Code Files plugin way before your plugin released and didn't realize it was still there.

But it may help if someone else reports the issue, or if you need to post some type of warning somewhere.

tejado commented 1 year ago

Oh great catch. Thanks a lot for analyzing and summarizing this so well! I will have a look and might add it to the readme.

Aetherinox commented 1 year ago

Sure thing. It's a very niche issue that has to have a series of things done in order for it to happen, but I figure somewhere out there, someone will have it happen at some point.

The only reason I caught it is I noticed when i finally did decrypt the note and open it in Obsidian, it showed the line numbers, and I thought that was weird. Then I looked at the plugin settings and sure enough, gpg was in Code Files settings.

Then I decided to test things, because well, I'm a developer too, and I don't like not knowing why something happens. It's a curse.

Aetherinox commented 11 months ago

Closing this since you've got all the info you need.