From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Martin Jerabek Newsgroups: gmane.emacs.bugs Subject: bug#58718: Incorrect regex in nXML URI check Date: Sat, 22 Oct 2022 14:58:28 +0200 Message-ID: <938384610b8c5411944afa7fae860f15e2e40eae.camel@fastmail.fm> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-i4WBrKlmS32bIaF+cPsI" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2553"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) To: 58718@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 24 04:39:06 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1omnMm-0000Ob-M0 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Oct 2022 04:39:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omhum-00044G-HQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Oct 2022 16:49:48 -0400 Original-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 1omGEE-0008RK-QD for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 11:16:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omGEE-0005qY-BE for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 11:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1omGEE-0001X3-3A for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 11:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Martin Jerabek Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Oct 2022 15:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58718 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16664517395858 (code B ref -1); Sat, 22 Oct 2022 15:16:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Oct 2022 15:15:39 +0000 Original-Received: from localhost ([127.0.0.1]:42183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omGDq-0001WO-9b for submit@debbugs.gnu.org; Sat, 22 Oct 2022 11:15:39 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:44982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omE5E-00062u-NV for submit@debbugs.gnu.org; Sat, 22 Oct 2022 08:58:38 -0400 Original-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 1omE5E-0002ry-Hj for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 08:58:36 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omE5C-0006Yo-9U for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 08:58:36 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 1F86C5C0092 for ; Sat, 22 Oct 2022 08:58:31 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sat, 22 Oct 2022 08:58:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailservice.ms; h=cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm2; t= 1666443511; x=1666529911; bh=czYil7eeQcTHLwi67995Pqb5RUXgPT6bsxu f5EX+JZw=; b=aDDnLGuRkTbAj9fp/r2dVKaAWwyVusnDT+kxCSwg5YdEKWB4Dko MWIfq7K1YqqdesmKr+9I09Et01qXT4WskIfz4dijvsL3I/fHcKGtMI5sZioK2R+P 3jVE/ta70h8drvKpUd6hfGnt3Lvf/SpTPVgZdoiPlH6yC5PCb0DSvUocGRZUYQVt aze7SP96aSRB7c+lDYHRAI7QArO8VsJ+G8eO41BiiJ3AEHsDamRZ5TYqVy+6K3oG /LoHDpPQeM6q3O+4Ramryj+O/nmjWvbvTzTuZjYaBWP7ZbcFxnuKEBbtsL5UvoYf XQfg/9QdDwkDrGiw6yu61ji7BAzG01UgmlA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1666443511; x= 1666529911; bh=czYil7eeQcTHLwi67995Pqb5RUXgPT6bsxuf5EX+JZw=; b=R wZiX6olP6jwBt8PclJXF3GdazXKOApz7NYoKf63La8EvAZKjUsqDo37gEAr1JQeK RdkJ2Ip3pMjVWLFwCpfZQK/Kugxgum3k85e3XULo3Mg3cPnaVGQ7hZ482vaDfvNp RqGXwnQPUf5kJ5C/sGv7U1OzvXuq9ZgcA3dFEAhRQoNrorSV0UV+Db5PbLiGdgOt uuEjWq/Q0/jskrlIznwz+r3MRHc4kB+5o+x/XgxoFV6uWMiwBXg6VF27EEzSx+Ze qnmrOGfPmrOCArWj+365lqKVzOeIzxhKLV7LbG/eMJ8DO9TKpt1TGvI3bEboA/fV RkbvA44Xik0C0p/EEnc5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgedttddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkuffhvffftggfggesmhdtreertd erjeenucfhrhhomhepofgrrhhtihhnucflvghrrggsvghkuceoohhmsehmrghilhhsvghr vhhitggvrdhmsheqnecuggftrfgrthhtvghrnhepvdduudeiveetledtieejtdejueethf evudffjeegffeuteffgfdvjeeuteegleevnecuffhomhgrihhnpehfvgguohhrrghprhho jhgvtghtrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohhmsehmrghilhhsvghrvhhitggvrdhmsh X-ME-Proxy: Feedback-ID: i49c94607:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 22 Oct 2022 08:58:30 -0400 (EDT) Received-SPF: pass client-ip=66.111.4.26; envelope-from=om@mailservice.ms; helo=out2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 22 Oct 2022 11:15:36 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:246055 Archived-At: --=-i4WBrKlmS32bIaF+cPsI Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi! In the function rng-uri-file-name-1 (file lisp/nxml/rng-uri.el line 71) the regular expression to check the passed URI is wrong. It is intended to make sure that special characters in the URI are correctly encoded, i.e. that the percent sign is followed by exactly two hex digits. The relevant part of the regular expression is %[[:xdigit:]]{2} However, the curly braces only have their special meaning of specifying the number of repetitions if they are escaped by a backslash. Otherwise they are interpreted as literal braces, so the current regular expression would only match a percent sign followed by one hex digit followed by the literal string "{2}". I stumbled upon this problem when trying to edit an XML file located in a path whose name contained space characters. Associating a RELAX-NG schema with this file (in the schemas.xml file) and reloading the file with rng-auto-set-schema-and-validate resulted in the error message "Bad escapes in URI 'file:///home/user/path%20with%20spaces/foo.rnc'" I used a path without spaces to work around this problem for the time being. As far as I can tell, this bug has existing since the first version of rng-uri.el, i.e. it has never worked as intended (unless the Emacs regular expression syntax changed in the meantime). I am using Emacs 28.1 from the current Fedora 36 package but I checked out the master branch of the Emacs source code to make sure that the problem still exists there. Find attached a patch to fix this problem. I hope it is trivial enough to be applied without a formal copyright assignment (it just adds four backslashes). Best regards Martin Jerabek In GNU Emacs 28.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-07-15 built on buildhw-x86-02.iad2.fedoraproject.org Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: Fedora Linux 36 (Workstation Edition) Configured using: 'configure --build=3Dx86_64-redhat-linux-gnu --host=3Dx86_64-redhat-linux-gnu --program-prefix=3D --disable-dependency-tracking --prefix=3D/usr --exec-prefix=3D/usr --bindir=3D/usr/bin --sbindir=3D/usr/sbin --sysconfdir=3D/etc --datadir=3D/usr/share --includedir=3D/usr/include --libdir=3D/usr/lib64 --libexecdir=3D/usr/libexec --localstatedir=3D/var sharedstatedir=3D/var/l= ib ----mandir=3D/usr/share/man infodir=3D/usr/share/info --with-dbus with-gif ------with-jpeg --with-png with-rsvg --with-tiff --with-xpm ----with-x-toolkit=3Dgtk3 --with-gpm=3Dno with-xwidgets --with-modules ----with-harfbuzz --with-cairo --with-json with-native-compilation --build_alias=3Dx86_64-redhat-linux-gnu host_alias=3Dx86_64-redhat-linux-gnu CC=3Dgcc 'CFLAGS=3D-DMAIL_USE_LOCKF -= O2 -flto=3Dauto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches pipe --Wall -Werror=3Dformat-security -Wp,-D_FORTIFY_SOURCE=3D2 -Wp,-D_GLIBCXX_ASSERTIONS specs=3D/usr/lib/rpm/redhat/redhat-hardened- cc1 --fstack-protector-strong specs=3D/usr/lib/rpm/redhat/redhat-annobin-cc1 --m64 -mtune=3Dgeneric fasynchronous-unwind-tables --fstack-clash-protection -fcf-protection' LDFLAGS=3D-Wl,-z,relro PKG_CONFIG_PATH=3D:/usr/lib64/pkgconfig:/usr/share/pkgconfig' --=-i4WBrKlmS32bIaF+cPsI Content-Disposition: attachment; filename="rng-uri.patch" Content-Type: text/x-patch; name="rng-uri.patch"; charset="UTF-8" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvbnhtbC9ybmctdXJpLmVsIGIvbGlzcC9ueG1sL3JuZy11cmkuZWwK aW5kZXggNzdmZWQ4YzMyZC4uMGE2ZmEzOWFjYiAxMDA2NDQKLS0tIGEvbGlzcC9ueG1sL3JuZy11 cmkuZWwKKysrIGIvbGlzcC9ueG1sL3JuZy11cmkuZWwKQEAgLTY4LDcgKzY4LDcgQEAgU2lnbmFs IGFuIGVycm9yIGlmIFVSSSBpcyBub3QgYSB2YWxpZCBmaWxlIFVSTC4iCiAKIDs7IHBhdHRlcm4g aXMgZWl0aGVyIG5pbCBvciBtYXRjaCBvciByZXBsYWNlCiAoZGVmdW4gcm5nLXVyaS1maWxlLW5h bWUtMSAodXJpIHBhdHRlcm4pCi0gICh1bmxlc3MgKHN0cmluZy1tYXRjaCAiXFxgXFwoPzpbXiVd XFx8JVtbOnhkaWdpdDpdXXsyfVxcKSpcXCciIHVyaSkKKyAgKHVubGVzcyAoc3RyaW5nLW1hdGNo ICJcXGBcXCg/OlteJV1cXHwlW1s6eGRpZ2l0Ol1dXFx7MlxcfVxcKSpcXCciIHVyaSkKICAgICAo cm5nLXVyaS1lcnJvciAiQmFkIGVzY2FwZXMgaW4gVVJJIGAlcyciIHVyaSkpCiAgIChzZXRxIHVy aSAocm5nLXVyaS11bmVzY2FwZS1tdWx0aWJ5dGUgdXJpKSkKICAgKGxldCogKChjb21wb25lbnRz Cg== --=-i4WBrKlmS32bIaF+cPsI--