From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sHAMLZ+7sWLUTQAAbAwnHQ (envelope-from ) for ; Tue, 21 Jun 2022 14:37:51 +0200 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id oOQHLZ+7sWLzagAA9RJhRA (envelope-from ) for ; Tue, 21 Jun 2022 14:37:51 +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 aspmx2.migadu.com (Postfix) with ESMTPS id 33BBE309B9 for ; Tue, 21 Jun 2022 14:37:51 +0200 (CEST) Received: from localhost ([::1]:39144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3d8f-0001dz-VY for larch@yhetil.org; Tue, 21 Jun 2022 08:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3d6M-0000OG-FW for emacs-orgmode@gnu.org; Tue, 21 Jun 2022 08:35:26 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:37404) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3d6H-0001dl-Os for emacs-orgmode@gnu.org; Tue, 21 Jun 2022 08:35:23 -0400 Received: by mail-ej1-x62b.google.com with SMTP id lw20so4841703ejb.4 for ; Tue, 21 Jun 2022 05:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fgwl3AjQFknZX6yiYkd4mv7zNkgp68Tdf2SG3xil4Sg=; b=jL1/alTY7iKWqwuNkt98oOWXDykYLjedOn00Zbr1u5O3HV5X+Y1NhOHa4DXwQvnSAv Fa903V8r8W2Z8vBUACXP7lVVNkftg5EFm0mZroUHvdsQVL8jCQI/h/OCXSR4yA5QfcNC an2f99Fhnwg7yNGW7qlSqdBVexlcydlgHoba6KcyWcV/Xol0Y0vca/rHr6cJi7EU+FNQ Gk9BgivEM2LhOV2qTYmWe64u+14dyCxK/T4BG3fh8gk1ddGWRcFwQsuyS4ZO4TiWuqNj P/z+myNC1+T1oPyf3eATSwIjmyYZ9SQ2g1wUEzRBdKVBXnFqHOXEE6eo1QcV+hNL/Z5C cVsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fgwl3AjQFknZX6yiYkd4mv7zNkgp68Tdf2SG3xil4Sg=; b=t/nJtZwXYY8207Xq4qinA93gIvLKFFY0jE0JzHDYMCQJp8/ud7jzki0iEublMJe1fk WbvbSIjzfFY2+yGtpvrPjdvkAoFrv+BeUrEkNzM+GqTxsNQo/Fk0iOAotd4hS7yx8tNK 7bf58TK5fTZ60hX1OXXUYgKTnEq5NMGE8ImgWsxO4S6J+1erVDyNbYkJnKJWKSHAimAz 2WgJfoRyyxtk5IfokecI8Wi1nrm+gl/wRMYYPZvemK+W62DjAe4dWTNe49EaNttxK6w3 +36WVQOPpw19Wes5QEAVx5MF8QBpoyZflUu5rrwj1qJbQA9vo+6Tg+Nx8pBqJtmbawJ7 vmKg== X-Gm-Message-State: AJIora9rweNUc7upEyYvH3TSJbvsEbpJqccaLm+dCyz4QUKUl6KdqoNR QIRb54JznwnruYAc4gICwOg= X-Google-Smtp-Source: AGRyM1vCxXfbCY4p1Pi0HLwq2EUAEkE1lUm3rF+9UTfKMERBKIgC2+Ms1/u6QHbg2+UyImEQpsloig== X-Received: by 2002:a17:907:ea6:b0:708:1282:cbe8 with SMTP id ho38-20020a1709070ea600b007081282cbe8mr26955638ejc.520.1655814920085; Tue, 21 Jun 2022 05:35:20 -0700 (PDT) Received: from localhost.localdomain ([2001:718:1e03:ffc2:fd72:a629:e6a5:7268]) by smtp.gmail.com with ESMTPSA id z21-20020aa7d415000000b0043566884333sm9348944edq.63.2022.06.21.05.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 05:35:19 -0700 (PDT) From: David Lukes To: dafydd.lukes@gmail.com Cc: emacs-orgmode@gnu.org Subject: [PATCH] ox.el: Protect export from auto-formatting hooks Date: Tue, 21 Jun 2022 14:36:06 +0200 Message-Id: <20220621123606.162399-1-dafydd.lukes@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=dafydd.lukes@gmail.com; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655815071; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Fgwl3AjQFknZX6yiYkd4mv7zNkgp68Tdf2SG3xil4Sg=; b=FOA+AdyHke3RwpUeUyKyfgrDlcm6QSP6pktFMczRExET+6twVtFC6GjZ5wlwrMmZl1JFZA jfFQKKZ3ROPCN1jktfz8kAQJG6ASEjy90a9a0lfq+86k+ScK0qcqh8bTNhRUMAFmbZwmHB zWD1d1jOvio8fuR6+pwFw0FEgNmFCHi9JBQrq/2KLkDU/+04xEdiePNdSUroNL70WT97KR aqkeocnUwF3yhfCMjw/gywWVQ+9SPnsCWOXZZYhTRxiZVLWj8uGuvlOWbX012TJijCyHQW AqYuyzCMlvMdpAh7XgLRzRDQNDG7RkUjrmH4CKk5vCaIdCVxGDvgZc6mV+33gg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655815071; a=rsa-sha256; cv=none; b=ryFSmuY1mNiQa3PMp3y2RM9POHQNYfUhzVFQUhNIve5ygwmY6gYKSWSi+hhT5B0Ok5rSxn cyqMepKO/LBTmH5bN21pWWIT5cKeJjOkmR9fQMZnnwS5aF/TGDNBFFr1kXWj7qracFLL2k rLmYxSTvDp6BcXstZU2VwRbqOdAZrqizY5ZncrXMIp/mk59qpsR3/bvnLAllIKuS31b7Mb elw2qZOzTHRTJ0LizbsTUolaRcnvPZfIhVD0dFMULvaaUhRQHQSxuwuebC3vqI7ppaiI1r muCKgJr29GwePCiGhqJFfkCkg4fN8rrXnjtw04JhyMRqny/bF/NexvEoiQtZhg== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="jL1/alTY"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx2.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: -3.47 Authentication-Results: aspmx2.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="jL1/alTY"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx2.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-Queue-Id: 33BBE309B9 X-Spam-Score: -3.47 X-Migadu-Scanner: scn1.migadu.com X-TUID: Im/mU5Hk0Cpc * ox.el, ox-odt.el: Use `write-region' instead of `write-file' or `save-buffer' to protect generated export buffers from auto-formatting hooks. In particular, `tidy' is often configured as the auto-formatter for HTML and XML, and it can corrupt the exports. TINYCHANGE --- lisp/ox-odt.el | 4 ++-- lisp/ox.el | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 9d47067..ec1c360 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -1411,7 +1411,7 @@ original parsed data. INFO is a plist holding export options." (level (string-to-number (match-string 2)))) (if (wholenump sec-num) (<= level sec-num) sec-num)) (replace-match replacement t nil)))) - (save-buffer 0))) + (write-region nil nil buffer-file-name))) ;; Update content.xml. (let* ( ;; `org-display-custom-times' should be accessed right @@ -4004,7 +4004,7 @@ contextual information." ;; Prettify output if needed. (when org-odt-prettify-xml (indent-region (point-min) (point-max))) - (save-buffer 0))))) + (write-region nil nil buffer-file-name))))) ;; Run zip. (let* ((target --out-file) (target-name (file-name-nondirectory target)) diff --git a/lisp/ox.el b/lisp/ox.el index c75357b..66d18c4 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -6553,14 +6553,14 @@ or FILE." (with-temp-buffer (insert output) (let ((coding-system-for-write ',encoding)) - (write-file ,file))) + (write-region nil nil ,file))) (or (ignore-errors (funcall ',post-process ,file)) ,file))) (let ((output (org-export-as backend subtreep visible-only body-only ext-plist))) (with-temp-buffer (insert output) (let ((coding-system-for-write encoding)) - (write-file file))) + (write-region nil nil file))) (when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p output)) (org-kill-new output)) ;; Get proper return value. -- 2.36.1