From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ODA5E7Z7TmRrMAAASxT56A (envelope-from ) for ; Sun, 30 Apr 2023 16:31:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id IOBGE7Z7TmT4qgAA9RJhRA (envelope-from ) for ; Sun, 30 Apr 2023 16:31:18 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DC4B62CD87 for ; Sun, 30 Apr 2023 16:31:17 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pt84o-000535-T2; Sun, 30 Apr 2023 10:30:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pt84n-00052r-Nd for emacs-orgmode@gnu.org; Sun, 30 Apr 2023 10:30:57 -0400 Received: from mail.choca.pics ([80.67.172.235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pt84l-0001b0-OF for emacs-orgmode@gnu.org; Sun, 30 Apr 2023 10:30:57 -0400 Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id D601D1807D639; Sun, 30 Apr 2023 16:30:42 +0200 (CEST) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id PhH8FxntKO6Z; Sun, 30 Apr 2023 16:30:42 +0200 (CEST) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 355101807FF31; Sun, 30 Apr 2023 16:30:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id MjuGJUWRmxfX; Sun, 30 Apr 2023 16:30:41 +0200 (CEST) Received: from localhost (91.60.75.86.rev.sfr.net [86.75.60.91]) by mail.choca.pics (Postfix) with ESMTPSA id C325F1807D639; Sun, 30 Apr 2023 16:30:41 +0200 (CEST) From: Damien Cassou To: emacs-orgmode@gnu.org Cc: Ihor Radchenko Subject: [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/)] Date: Sun, 30 Apr 2023 16:30:41 +0200 Message-ID: <87ttwxphm6.fsf@cassou.me> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=80.67.172.235; envelope-from=damien@cassou.me; helo=mail.choca.pics X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682865077; a=rsa-sha256; cv=none; b=qrh3pWWXmeG+86FgsXqlMugcz3mMteZqBVd+v1DfGbay6sbVTWkLLqTdegm7p5zqm11Fkq eDdN/fcCumqgzxjgpwZc/twF2SKgCqpdymm7OeHQYe/OcF+kkjeq59KbYnk7rldW8sldRF 3KgkiLmasIqewUZFSbDXuU5S/+grSx5HB240eP/v8wtAu+gw0Vrm3sTjtzn4iYbUC/OIyW YFIMUY4nSjr4gcZqJjXBY70sG5HlWclBVy+JXZA+GPP7B1hu5qVwwMH62A5lizLDEN4lBs 3KRENVxD8B/vHfgqHs1ukvtvs2slzhWTexorFxK27QaKV8sFY7PnEz0EnlPRsw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682865077; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=3yG4AF2FKnnOVTh78HzI/GkNXpbyqGdRpkAQ2eg+UJs=; b=OrsgQqCawfOs2hn9RhLunwQSdZTrNFFGnAl4MzmroTgsT/r/Jv6n8KHld6wJO3B/mBF4cK qwoCA1JYrKA5N0GCI0UnWNaCpjdXgDhbCDnyJ38x5ElAbXVw3V+uQsWhSZhibs9hEPPV+O CwimrRFYv7Bwbc8Vfgl2C8z9Vvbgj51vGnSCtU0JfyPuT33qWw4sXdTBnL+4SLXFoHIWE8 7lREJHtorJ7GL2PP3yVrVAwEVWFFEMLwJrR8pO+VotCYW2CQYp+5YvKYmIyjEuYZWJ06lN GDh3uPLMSWdtsC7GM3m2vGAG+TVfDDy3FWNw3s4fRqVvADsaP61NG+s1yTntnw== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.50 X-Spam-Score: -1.50 X-Migadu-Queue-Id: DC4B62CD87 X-TUID: N5gXmWkq8TBs --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-odt-plain-text-Fix-when-text-contains-only-space.patch >From 7d41bd49bc22d457a2a84e360b3ab4dc22eb587a Mon Sep 17 00:00:00 2001 From: Damien Cassou 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 --=-=-=--