all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] [PATCH] org-odt-plain-text: Fix when text contains only spaces [9.7-pre (release_9.6.4-346-g7d41bd @ /home/cassou/.emacs.d/lib/org/lisp/)]
@ 2023-04-30 14:30 Damien Cassou
  2023-04-30 17:27 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Damien Cassou @ 2023-04-30 14:30 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Ihor Radchenko

[-- Attachment #1: Type: text/plain, Size: 992 bytes --]

Hi,

in [1], Ihor fixed a bug I reported in ox-odt. Unfortunately, this fix
broke figures with several lines of captions such as:

    #+CAPTION: first line,
    #+CAPTION: second line
    [[file:media/myPicture.png]]

This is because, in this case, org-odt-plain-text is called at some
point with " " as value for `text`. In this context, both `leading` and
`trailing` temporary variables contain the same value as `text`, making
the `substring` call crash.

The attached patch fixes the issue by considering that there is no
leading/trailing content when the input only contains spaces.

Best

[1] https://list.orgmode.org/orgmode/87v8i3y135.fsf@cassou.me/

Emacs  : GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
Package: Org mode version 9.7-pre (release_9.6.4-346-g7d41bd @ /home/cassou/.emacs.d/lib/org/lisp/)
-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-odt-plain-text-Fix-when-text-contains-only-space.patch --]
[-- Type: text/x-patch, Size: 998 bytes --]

From 7d41bd49bc22d457a2a84e360b3ab4dc22eb587a Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Sun, 30 Apr 2023 16:18:30 +0200
Subject: [PATCH] org-odt-plain-text: Fix when text contains only spaces

* lisp/ox-odt.el (org-odt-plain-text): Do not crash when input only
consists of spacing.
---
 lisp/ox-odt.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 2ac34c8db..15c9037e9 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2927,6 +2927,9 @@ (defun org-odt-plain-text (text info)
                                     (match-string 0 output)))
                       (trailing (and (string-match (rx (1+ blank) eos) output)
                                      (match-string 0 output))))
+                  (when (length= leading (length output))
+                    (setq leading "")
+                    (setq trailing ""))
                   (insert
                    (substring
                     output
-- 
2.38.4


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

* Re: [BUG] [PATCH] org-odt-plain-text: Fix when text contains only spaces [9.7-pre (release_9.6.4-346-g7d41bd @ /home/cassou/.emacs.d/lib/org/lisp/)]
  2023-04-30 14:30 [BUG] [PATCH] org-odt-plain-text: Fix when text contains only spaces [9.7-pre (release_9.6.4-346-g7d41bd @ /home/cassou/.emacs.d/lib/org/lisp/)] Damien Cassou
@ 2023-04-30 17:27 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2023-04-30 17:27 UTC (permalink / raw)
  To: Damien Cassou; +Cc: emacs-orgmode

Damien Cassou <damien@cassou.me> writes:

> in [1], Ihor fixed a bug I reported in ox-odt. Unfortunately, this fix
> broke figures with several lines of captions such as:
>
>     #+CAPTION: first line,
>     #+CAPTION: second line
>     [[file:media/myPicture.png]]
>
> This is because, in this case, org-odt-plain-text is called at some
> point with " " as value for `text`. In this context, both `leading` and
> `trailing` temporary variables contain the same value as `text`, making
> the `substring` call crash.

Thanks for the heads-up!
Fixed, on bugfix. Alongside with a couple of ox-odt improvements on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c756f8a85

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c265d964f
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a686c7b60

> The attached patch fixes the issue by considering that there is no
> leading/trailing content when the input only contains spaces.

I used an alternative approach.
Canceled. (for the patch)

-- 
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:[~2023-04-30 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-30 14:30 [BUG] [PATCH] org-odt-plain-text: Fix when text contains only spaces [9.7-pre (release_9.6.4-346-g7d41bd @ /home/cassou/.emacs.d/lib/org/lisp/)] Damien Cassou
2023-04-30 17:27 ` Ihor Radchenko

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.