emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix missing null check for tangle links during export
@ 2022-12-20  2:38 Tom Gillespie
  2022-12-21 12:42 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Gillespie @ 2022-12-20  2:38 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 220 bytes --]

Hi,
   Here is a patch that fixes broken tangling during export. I don't have a
simple reproduction, but was able to run git bisect to find the originating
commit. The commit text explains the issue in detail. Best,
Tom

[-- Attachment #1.2: Type: text/html, Size: 283 bytes --]

[-- Attachment #2: 0001-Fix-missing-null-check-for-tangle-links-during-expor.patch --]
[-- Type: text/x-patch, Size: 1978 bytes --]

From 0b4e35453874db0acf046e46c571cdef5f39f59a Mon Sep 17 00:00:00 2001
From: Tom Gillespie <tgbugs@gmail.com>
Date: Mon, 19 Dec 2022 21:25:02 -0500
Subject: [PATCH] Fix missing null check for tangle links during export

* lisp/ob-tangle.el (org-babel-tangle--unbracketed-link): Add the let
bound variable l to the and statement to prevent l from being passed
to `string-match' in the event that it is nil.

When tangling nested noweb blocks during export it is possible for the
results of `org-store-link' to return nil.  This commit ensures that
the value returned for l is only passed to `string-match' when it is
non-nil, avoiding a `wrong-type-argument' (stringp nil) error.

Handling of comments and nesting of babel blocks is known to have
issues.  The bug is from 8a781d35dc68f20fa2a5546c98ba3d9b77ee3cda
where new code was introduced to obtain the value for bare which was
not present in early code.  I'm guessing that the bug appears now
because `string-match' is called on l (aka link) at a point in time
when it was never previously called and it was thus masked because in
the old version it was impossible to call `string-match' when `link'
was nil because another variable was always nil, masking the issue.
---
 lisp/ob-tangle.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index bd17bda32..fd6b6f3b9 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -500,7 +500,8 @@ The PARAMS are the 3rd element of the info for the same src block."
                  (cl-letf (((symbol-function 'org-store-link-functions)
                             (lambda () nil)))
                    (org-store-link nil))))
-             (bare (and (string-match org-link-bracket-re l)
+             (bare (and l
+                        (string-match org-link-bracket-re l)
                         (match-string 1 l))))
         (when bare
           (if (and org-babel-tangle-use-relative-file-links
-- 
2.38.2


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

* Re: [PATCH] Fix missing null check for tangle links during export
  2022-12-20  2:38 [PATCH] Fix missing null check for tangle links during export Tom Gillespie
@ 2022-12-21 12:42 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-12-21 12:42 UTC (permalink / raw)
  To: Tom Gillespie; +Cc: emacs-orgmode

Tom Gillespie <tgbugs@gmail.com> writes:

> Hi,
>    Here is a patch that fixes broken tangling during export. I don't have a
> simple reproduction, but was able to run git bisect to find the originating
> commit. The commit text explains the issue in detail. Best,
> Tom

Thanks!
Applied onto bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a8c9f1175

-- 
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] 2+ messages in thread

end of thread, other threads:[~2022-12-21 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-20  2:38 [PATCH] Fix missing null check for tangle links during export Tom Gillespie
2022-12-21 12:42 ` 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).