emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] org-protocol: Add void() to bookmarklets


From: Max Nikulin
Subject: Re: [PATCH] org-protocol: Add void() to bookmarklets
Date: Tue, 24 Dec 2024 21:14:17 +0700
User-agent: Mozilla Thunderbird

On 22/12/2024 19:42, Ihor Radchenko wrote:
Max Nikulin writes:

-javascript:location.href='org-protocol://store-link?' +
-      new URLSearchParams({url:location.href, title:document.title});
+javascript:void(location.href='org-protocol://store-link?' +
+      new URLSearchParams({url:location.href, title:document.title}));
  #+end_example

Another variant from reddit is

javascript:location.href='org-protocol://store-link?'+new 
URLSearchParams({url:location.href, title:document.title}); void(0);

If you think that ";void(0)" variant is less prone to errors then I may update my patch. I have no idea if balanced void(...) parenthesis around the whole expressions would cause more user mistakes. Otherwise both variants are equivalent.

https://old.reddit.com/r/emacs/comments/1h7ws1i/the_orgprotocol_bookmarklet_opens_a_blank_page/

I can not figure out why it did not work without user's ~/.local/share/applications/org-protocol.org. The only guess is that firefox might be confused by complex Exec entry in emacsclient.desktop. So I am curious if /usr/share/applications/emacsclient.desktop has org-protocol in MimeType (Emacs >= 29.2) and if a copy of emacsclient.desktop in ~/.local/share/application changes behavior in the absence of custom org-protocol.desktop.

I have never used bookmarklets, so I am unsure concerning behavior in earlier Firefox versions. Unfortunately security-related bugs are non-public yet, so I have not idea what has been changed. (I am not motivated to search for related commits.)

Also, will the change work in older browsers? In non-Firefox?

<https://en.wikipedia.org/wiki/Bookmarklet>
page has a citation that "void" appeared in JavaScript namely for bookmarklets and it happened in the previous century.

";undefined" instead of ";void(0)" suffix might be an issue in old browsers since "undefined" was added to JS ~10 years ago. I do not expect any problem with "void" despite I have used it only in workaround for a browser bug.

Should ORG-NEWS be updated as well?

Yes, I think. In announcement section.
This is one of the cases when we want people to consider changing their
usual configs.

My idea is to fix existing examples in place, perhaps with a small remark on update reason.

Maybe experienced users of bookmarklets are aware of the "void" trick and provided examples were enough for them.

I consider the change as a minor fix that does not deserves loud announcement, especially taking into account that browsers discourages protocol handlers launched on behalf of web pages nowadays.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]