emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Lin Sun <sunlin7@hotmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: [BUG] dead loop on (org-table-clean-line "|a|b|") [9.6 (release_9.6-3-ga4d38e @ share/emacs/29.0.60/lisp/org/)]
Date: Fri, 2 Dec 2022 07:37:59 +0000	[thread overview]
Message-ID: <TYCP286MB1986CF00EA8BC2BF01503E5BFB179@TYCP286MB1986.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <874juf3cnu.fsf@localhost>


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

Hi Ihor,

> I cannot reproduce.
> Can you please provide detailed steps starting from emacs -Q?

The bug caused by the function org-table-clean-line​ calls the org-string-width​ inside a string-match​ clause without protection, for the org-string-width​ maybe change the match data then cause the string-match run into wrong result.

The attachment is a quick patch for the issue, please help to review and apply it, thanks



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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-table.el-fix-match-data-changed-in-org-table-cle.patch --]
[-- Type: text/x-patch; name="0001-org-table.el-fix-match-data-changed-in-org-table-cle.patch", Size: 909 bytes --]

From 428f989c6e9f846cf6a1bbb25ada56146789a2c6 Mon Sep 17 00:00:00 2001
From: Lin Sun <lin.sun@zoom.us>
Date: Fri, 2 Dec 2022 07:31:05 +0000
Subject: [PATCH] org-table.el: fix match-data changed in org-table-clean-line

---
 lisp/org-table.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index b160dc97c..6e6835fba 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1699,7 +1699,7 @@ In particular, this does handle wide and invisible characters."
       (setq s (mapconcat (lambda (x) (if (member x '(?| ?+)) "|" " ")) s ""))
     (while (string-match "|\\([ \t]*?[^ \t\r\n|][^\r\n|]*\\)|" s)
       (setq s (replace-match
-	       (concat "|" (make-string (org-string-width (match-string 1 s))
+	       (concat "|" (make-string (save-match-data (org-string-width (match-string 1 s)))
 					?\ ) "|")
 	       t t s)))
     s))
-- 
2.20.5


  reply	other threads:[~2022-12-02  7:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 22:19 [BUG] dead loop on (org-table-clean-line "|a|b|") [9.6 (release_9.6-3-ga4d38e @ share/emacs/29.0.60/lisp/org/)] Lin Sun
2022-12-01  5:39 ` Ihor Radchenko
2022-12-02  7:37   ` Lin Sun [this message]
2022-12-02  6:40     ` Ihor Radchenko
2022-12-02 22:18       ` Lin Sun
2022-12-02  7:40     ` Lin Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=TYCP286MB1986CF00EA8BC2BF01503E5BFB179@TYCP286MB1986.JPNP286.PROD.OUTLOOK.COM \
    --to=sunlin7@hotmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).