emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Using search options in HTTP-style links
@ 2024-04-15  7:04 Joseph Turner
  2024-04-15 11:48 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Turner @ 2024-04-15  7:04 UTC (permalink / raw)
  To: Org Mode Mailing List; +Cc: Adam Porter, Jonas Bernoulli, Protesilaos Stavrou

Hello!

[[info:org#Search Options]] says that search options are intended for
file: type links only.  However, since Org documents can also be loaded
over network protocols like HTTP and hyper://, I'd like to deliberate
if/how search options might be encoded inside HTTP-style link fragments.

HTTP-style links are URL-encoded with "#"-prefixed link fragments:

(let ((domain "https://ushin.org")
      (filename "needs-list.org")
      (search-option "::#care"))
  (format "%s/%s#%s" domain (url-hexify-string filename)
          (url-hexify-string search-option)))

=>  "https://ushin.org/needs-list.org#%3A%3A%23care"

Currently, loading the above URL with EWW...

(eww "https://ushin.org/needs-list.org#%3A%3A%23care")

...loads the file in eww-mode with point at the top of the file.

I think it would be more useful to instead activate org-mode (or a mode
which derives from it - "eww-org-mode"?), decode the link fragment, and
then jump to the location specified by the search option.

Web browsers like Firefox don't handle Org search options in link
fragments, but then again, they don't handle Org documents at all.  On my
machine, loading https://ushin.org/needs-list.org#%3A%3A%23care in
Firefox downloads the file as if the fragment weren't there.

What other issues might arise when encoding search options this way?

Any other comments/questions welcome :)

Thank you!

Joseph


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using search options in HTTP-style links
  2024-04-15  7:04 Using search options in HTTP-style links Joseph Turner
@ 2024-04-15 11:48 ` Ihor Radchenko
  2024-04-15 23:55   ` Joseph Turner
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-04-15 11:48 UTC (permalink / raw)
  To: Joseph Turner
  Cc: Org Mode Mailing List, Adam Porter, Jonas Bernoulli,
	Protesilaos Stavrou

Joseph Turner <joseph@ushin.org> writes:

> ...
> (eww "https://ushin.org/needs-list.org#%3A%3A%23care")
>
> ...loads the file in eww-mode with point at the top of the file.
>
> I think it would be more useful to instead activate org-mode (or a mode
> which derives from it - "eww-org-mode"?), decode the link fragment, and
> then jump to the location specified by the search option.

There is a convention for pdfs:
http://www.example.com/document.pdf#page=5
But, AFAIK, it is not RFC.

So, there is nothing stopping from creating an ad-hoc convention to
parse URL locators in links to PDFs or org files or whatnot.

However, the question about activating a major mode on web content is a
question to Emacs developers. It should be considered carefully, because
activating major modes may not be safe.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using search options in HTTP-style links
  2024-04-15 11:48 ` Ihor Radchenko
@ 2024-04-15 23:55   ` Joseph Turner
  2024-04-22 20:02     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Turner @ 2024-04-15 23:55 UTC (permalink / raw)
  To: Ihor Radchenko
  Cc: Org Mode Mailing List, Adam Porter, Jonas Bernoulli,
	Protesilaos Stavrou

Ihor Radchenko <yantar92@posteo.net> writes:

> Joseph Turner <joseph@ushin.org> writes:
>
>> ...
>> (eww "https://ushin.org/needs-list.org#%3A%3A%23care")
>>
>> ...loads the file in eww-mode with point at the top of the file.
>>
>> I think it would be more useful to instead activate org-mode (or a mode
>> which derives from it - "eww-org-mode"?), decode the link fragment, and
>> then jump to the location specified by the search option.
>
> There is a convention for pdfs:
> http://www.example.com/document.pdf#page=5
> But, AFAIK, it is not RFC.
>
> So, there is nothing stopping from creating an ad-hoc convention to
> parse URL locators in links to PDFs or org files or whatnot.

I'll need to dig a little more to see what changes would need to be made
in order for org-store-link to store properly formatted search options
with http: or hyper: links.  Currently, org-create-file-search-functions
is only used when creating a file: link.

> However, the question about activating a major mode on web content is a
> question to Emacs developers. It should be considered carefully, because
> activating major modes may not be safe.

hyperdrive.el activates a major mode with set-auto-mode when content is
loaded over the network.  This behavior is on by default.  Do you have
any advice about this?

Should hyperdrive.el set untrusted-content to t?

Thanks!

Joseph


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using search options in HTTP-style links
  2024-04-15 23:55   ` Joseph Turner
@ 2024-04-22 20:02     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-04-22 20:02 UTC (permalink / raw)
  To: Joseph Turner
  Cc: Org Mode Mailing List, Adam Porter, Jonas Bernoulli,
	Protesilaos Stavrou

Joseph Turner <joseph@ushin.org> writes:

>> So, there is nothing stopping from creating an ad-hoc convention to
>> parse URL locators in links to PDFs or org files or whatnot.
>
> I'll need to dig a little more to see what changes would need to be made
> in order for org-store-link to store properly formatted search options
> with http: or hyper: links.  Currently, org-create-file-search-functions
> is only used when creating a file: link.

You can instead use :store link parameter. It takes precedence over
everything else in `org-store-link'.

>> However, the question about activating a major mode on web content is a
>> question to Emacs developers. It should be considered carefully, because
>> activating major modes may not be safe.
>
> hyperdrive.el activates a major mode with set-auto-mode when content is
> loaded over the network.  This behavior is on by default.  Do you have
> any advice about this?
>
> Should hyperdrive.el set untrusted-content to t?

I was mostly talking about commands like eww - I simply recall a similar
proposal being made about activating Org mode when the URL points to Org
file. That proposal has been rejected on the grounds of security. See
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58774

The case with hyperdrive.el is not the same.
You may want to discuss it on emacs-devel.

As for untrusted-content, there is no point using it now - it was
specifically introduced for Org mode. It may or may not become a part of
more general security framework in Emacs.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-22 20:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15  7:04 Using search options in HTTP-style links Joseph Turner
2024-04-15 11:48 ` Ihor Radchenko
2024-04-15 23:55   ` Joseph Turner
2024-04-22 20:02     ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).