* IMPORTANT Modified link escaping in Org mode
@ 2011-02-17 19:57 David Maus
2011-02-19 11:11 ` Bastien
2011-03-13 13:37 ` Michael Brand
0 siblings, 2 replies; 6+ messages in thread
From: David Maus @ 2011-02-17 19:57 UTC (permalink / raw)
To: org-mode
[-- Attachment #1.1.1: Type: text/plain, Size: 1615 bytes --]
Hello everybody,
I've just pushed a series of commits to current master that modifies
Org modes link escaping functions.
Percent escaping is used in Org mode to escape certain characters in
links that would either break the parser (e.g. square brackets in link
target oder description) or are not allowed to appear in a particular
link type (e.g. non-ascii characters in a http: link).
With this change in place Org will apply percent escaping and
unescaping more consistently especially for non-ascii characters.
Additionally some of the outstanding bugs or glitches concerning
percent escaped links are solved.
However, this change has the potential to break existing links in your
documents in at least one case: Links that contain a literal percent
sign followed by two characters in [0-9a-fA-f] might break if this
sequence of characters is /not/ a percent escape.
E.g. a link to a directory literally called "foo%45bar" will break
because the new unescaping function will happily interpret the "%45"
as a percent encoded letter "E".
To detect at least some of such problematic links you can run the
attached command `dmaus/org-check-percent-escapes' in a Org mode
buffer. It will scan all links in the buffer and issue a warning for
each link that contains a sequence that matches aformentioned pattern
and is not one of the escape sequences used by Org up to know.
If you experience any problems with this change please don't forget to
Cc: me so the complaints will end up in my main mailbox.
Best,
-- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de
[-- Attachment #1.1.2: dmaus-org-check-percent-escapes.el --]
[-- Type: application/octet-stream, Size: 849 bytes --]
(defun dmaus/org-check-percent-escapes ()
"*Check buffer for possibly problematic old link escapes."
(interactive)
(when (eq major-mode 'org-mode)
(let ((old-escapes '("%20" "%5B" "%5D" "%E0" "%E2" "%E7" "%E8" "%E9"
"%EA" "%EE" "%F4" "%F9" "%FB" "%3B" "%3D" "%2B")))
(unless (boundp 'warning-suppress-types)
(setq warning-suppress-types nil))
(widen)
(show-all)
(goto-char (point-min))
(while (re-search-forward org-any-link-re nil t)
(let ((end (match-end 0)))
(goto-char (match-beginning 0))
(while (re-search-forward "%[0-9a-zA-Z]\\{2\\}" end t)
(let ((escape (match-string-no-properties 0)))
(unless (member (upcase escape) old-escapes)
(warn "Found unknown percent escape sequence %s at buffer %s, position %d"
escape
(buffer-name)
(- (point) 3))))))))))
[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: IMPORTANT Modified link escaping in Org mode
2011-02-17 19:57 IMPORTANT Modified link escaping in Org mode David Maus
@ 2011-02-19 11:11 ` Bastien
2011-02-20 10:34 ` David Maus
2011-03-13 13:37 ` Michael Brand
1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2011-02-19 11:11 UTC (permalink / raw)
To: David Maus; +Cc: org-mode
Thanks David for the detailed explanations.
Could you add the dmaus-org-check-percent-escapes.el function somewhere
in Worg/org-hacks.org? This will allow us to link to it when releasing
the next Org version.
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: IMPORTANT Modified link escaping in Org mode
2011-02-17 19:57 IMPORTANT Modified link escaping in Org mode David Maus
2011-02-19 11:11 ` Bastien
@ 2011-03-13 13:37 ` Michael Brand
2011-03-13 16:04 ` David Maus
1 sibling, 1 reply; 6+ messages in thread
From: Michael Brand @ 2011-03-13 13:37 UTC (permalink / raw)
To: David Maus; +Cc: org-mode
Hi David
The current version of dmaus/org-check-percent-escapes from Worg
http://orgmode.org/worg/org-hacks.html#check-old-link-escapes
loops forever in the outer while when used on a one line Org buffer
containing just [[http://www.orgmode.org]] except I hack something
like (goto-char end) behind the inner while. What am I doing wrong?
Did anybody else have this issue?
Michael
On Thu, Feb 17, 2011 at 20:57, David Maus <dmaus@ictsoc.de> wrote:
> Hello everybody,
>
> I've just pushed a series of commits to current master that modifies
> Org modes link escaping functions.
>
> Percent escaping is used in Org mode to escape certain characters in
> links that would either break the parser (e.g. square brackets in link
> target oder description) or are not allowed to appear in a particular
> link type (e.g. non-ascii characters in a http: link).
>
> With this change in place Org will apply percent escaping and
> unescaping more consistently especially for non-ascii characters.
> Additionally some of the outstanding bugs or glitches concerning
> percent escaped links are solved.
>
> However, this change has the potential to break existing links in your
> documents in at least one case: Links that contain a literal percent
> sign followed by two characters in [0-9a-fA-f] might break if this
> sequence of characters is /not/ a percent escape.
>
> E.g. a link to a directory literally called "foo%45bar" will break
> because the new unescaping function will happily interpret the "%45"
> as a percent encoded letter "E".
>
> To detect at least some of such problematic links you can run the
> attached command `dmaus/org-check-percent-escapes' in a Org mode
> buffer. It will scan all links in the buffer and issue a warning for
> each link that contains a sequence that matches aformentioned pattern
> and is not one of the escape sequences used by Org up to know.
>
> If you experience any problems with this change please don't forget to
> Cc: me so the complaints will end up in my main mailbox.
>
> Best,
> -- David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: IMPORTANT Modified link escaping in Org mode
2011-03-13 13:37 ` Michael Brand
@ 2011-03-13 16:04 ` David Maus
0 siblings, 0 replies; 6+ messages in thread
From: David Maus @ 2011-03-13 16:04 UTC (permalink / raw)
To: Michael Brand; +Cc: David Maus, org-mode
[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]
At Sun, 13 Mar 2011 14:37:05 +0100,
Michael Brand wrote:
>
> Hi David
>
> The current version of dmaus/org-check-percent-escapes from Worg
> http://orgmode.org/worg/org-hacks.html#check-old-link-escapes
> loops forever in the outer while when used on a one line Org buffer
> containing just [[http://www.orgmode.org]] except I hack something
> like (goto-char end) behind the inner while. What am I doing wrong?
> Did anybody else have this issue?
Sorry, my fault. Forgot to move point forward after matching a link.
I pushed this fixed version to Worg:
#+begin_src emacs-lisp
(defun dmaus/org-check-percent-escapes ()
"*Check buffer for possibly problematic old link escapes."
(interactive)
(when (eq major-mode 'org-mode)
(let ((old-escapes '("%20" "%5B" "%5D" "%E0" "%E2" "%E7" "%E8" "%E9"
"%EA" "%EE" "%F4" "%F9" "%FB" "%3B" "%3D" "%2B")))
(unless (boundp 'warning-suppress-types)
(setq warning-suppress-types nil))
(widen)
(show-all)
(goto-char (point-min))
(while (re-search-forward org-any-link-re nil t)
(let ((end (match-end 0)))
(goto-char (match-beginning 0))
(while (re-search-forward "%[0-9a-zA-Z]\\{2\\}" end t)
(let ((escape (match-string-no-properties 0)))
(unless (member (upcase escape) old-escapes)
(warn "Found unknown percent escape sequence %s at buffer %s, position %d"
escape
(buffer-name)
(- (point) 3)))))
(goto-char end))))))
#+end_src
Best,
-- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de
[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-13 16:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-17 19:57 IMPORTANT Modified link escaping in Org mode David Maus
2011-02-19 11:11 ` Bastien
2011-02-20 10:34 ` David Maus
2011-02-22 11:21 ` Bastien
2011-03-13 13:37 ` Michael Brand
2011-03-13 16:04 ` David Maus
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).