From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WBHSAJKirWPlQgEAbAwnHQ (envelope-from ) for ; Thu, 29 Dec 2022 15:22:10 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MKWKO5GirWMVRQAAG6o9tA (envelope-from ) for ; Thu, 29 Dec 2022 15:22:09 +0100 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 B04C98F27 for ; Thu, 29 Dec 2022 15:22:09 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAtmq-0002cX-DF; Thu, 29 Dec 2022 09:21:38 -0500 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 1pAtmd-0002VQ-CD for emacs-orgmode@gnu.org; Thu, 29 Dec 2022 09:21:25 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAtmb-00014n-2Y for emacs-orgmode@gnu.org; Thu, 29 Dec 2022 09:21:23 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id BC88C240194 for ; Thu, 29 Dec 2022 15:21:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1672323678; bh=p6o+YSL95uYbwZ5DUjGmZs/fCZlf4lWsvNN7rhN9xaU=; h=From:To:Cc:Subject:Date:From; b=LIdnjis/k0uApcrEqsRkjZdS3/RKXftYsBITm5o9QMYfudblSqiGukN88PkZ3Bwgt 8iDAhDMcMA8Hz71ZjRxsvwAOLMV6PAe34/iEDg2l+g+IsUavv9nrpW7/LvRX/58Ftn LeaYiLI/tUBq+Oj/aUefA+w/tNIxhaM9uDmzg2eXzEwXcHcXnpBFwAQHCT1FajW2K4 P9m3+6nbTNBbx1jiSb4yR8DdpVPGL2L5vkGz17CHOaoYKPHnwP3Jz149SwBqw+9bbA Xf3BGY6KBAyZVYLPHEDH+DxJluoq7vUUQXxb+GOQEmwT5DOqbz6togpo6P7+kwRf2M pPkceJjSlvpWQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NjVtg51jvz9rxG; Thu, 29 Dec 2022 15:21:15 +0100 (CET) From: Ihor Radchenko To: Hugo Cisneros Cc: emacs-orgmode@gnu.org Subject: [PATCH] Throw an error when bibliography field is not properly parsed (was: [PATCH] oc-basic.el: Fix wrong type for the editors field when parsing JSON.) In-Reply-To: <87edsnsocj.fsf@localhost> References: <6964C697-B085-4554-9BA3-54A2E3C6DC22@gmail.com> <87edsnsocj.fsf@localhost> Date: Thu, 29 Dec 2022 14:21:06 +0000 Message-ID: <87r0withnx.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672323729; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=A+ups65bNduVpxK7dskPIc0NAt6Cv9EOkszbIb3EEBo=; b=KlBGIdnazC4CARJ6nR24VPibu1iaJhEIcQs6XRkad4G/JmegnUrB9s7kinRDFdbbE21R/x 1/znACXc5UOGCunLC5/e4HwyRTv8sOQThPyhkvjNMbWlnm/FFd4GcdgYKy/5aPGojLh0XA SH+jbSQNQ15zU7JXBc9eWTVfOZLZ4VV9dxzSS3WbMqtRn1bvIS4awvifzoGiR1dEA2Hk40 HGrFJCNI7Bv9uuGUFtk0EcPTP4uxa3C4QuHNRhHJfNKm9K30U0nTt+Mp6Z1use2o3YBSEd uu5cQg1ykMK9SGYrTkqtfTiMrEXakL9zJCTY7GqaGWIRSDimm/+Uu8QhyPxCIQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="LIdnjis/"; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672323729; a=rsa-sha256; cv=none; b=dHFMgXtXsjjb0IUDRHDB7Me8bvpopWEZQObe+fZXBFIhthHW4IS1RYliUM051lODAcVQQs PzPOegVeAUki0QU03I3FAHB1KsMmpg9EwbWr/fSPHyuin5Wy95pA7Yz+qJkWMbHsVO9mHE j9bKdU5z60BMlEI9Cah1eNh5lKTloJb9L6Iw8fllVJROLkHvnD+cj0rb+GdoCQOCFkGm/6 lLeBYPuOL6eDLW0d7k1gJ2ZCEUo+neEKV2PHuAbolrNngk4MTED1TxW1Ok1/IugyKfS19J /HIFkmmz0Z2tAw/qmfe365bZKayO/xP/bSG2VCxWE9s+msiD4PdbHGHsCJ1A6w== X-Spam-Score: -4.46 X-Migadu-Queue-Id: B04C98F27 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="LIdnjis/"; 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"; dmarc=pass (policy=none) header.from=posteo.net X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -4.46 X-TUID: NNeRU7vQmraY --=-=-= Content-Type: text/plain Ihor Radchenko writes: >> As explained in the ChangeLog entry, this points to a more general issue where >> `org-cite-basic--get-field' is expected to return nil or a string, but calls >> `org-cite-basic--get-entry' that may return an association list. I am not sure >> how to fix that since it means converting anything that >> `org-cite-basic--get-entry' may return into a string. > > Non-string can only be for JSON bibliographies for fields that are not > supported. `org-cite-basic--get-field' can probably return nil in such > scenarios. I am attaching tentative patch that will make `org-cite-basic--get-field' throw an error when the filed value is not a string. I would appreciate testing. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-cite-basic-get-field-Throw-an-error-on-non-nil-f.patch >From 9fe6284fdc7ceeb0e0aa8e5a58b6828ca415b6b2 Mon Sep 17 00:00:00 2001 Message-Id: <9fe6284fdc7ceeb0e0aa8e5a58b6828ca415b6b2.1672323564.git.yantar92@posteo.net> From: Ihor Radchenko Date: Thu, 29 Dec 2022 17:18:35 +0300 Subject: [PATCH] org-cite-basic--get-field: Throw an error on non-nil field values * lisp/oc-basic.el (org-cite-basic--get-field): Throw an error when the field value is not a string. Document the new behavior. Link: https://orgmode.org/list/87edsnsocj.fsf@localhost --- lisp/oc-basic.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el index 01e314bfd..8e69db03c 100644 --- a/lisp/oc-basic.el +++ b/lisp/oc-basic.el @@ -332,7 +332,9 @@ (defun org-cite-basic--get-field (field entry-or-key &optional info raw) Return value may be nil or a string. If current export back-end is derived from `latex', return a raw string instead, unless optional argument RAW is -non-nil." +non-nil. + +Throw an error if the field value is non-string and non-nil." (let ((value (cdr (assq field @@ -343,6 +345,8 @@ (defun org-cite-basic--get-field (field entry-or-key &optional info raw) entry-or-key) (_ (error "Wrong value for ENTRY-OR-KEY: %S" entry-or-key))))))) + (unless (and value (stringp value)) + (error "Non-string bibliography field value: %S" value)) (if (and value (not raw) (org-export-derived-backend-p (plist-get info :back-end) 'latex)) -- 2.38.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--