From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Benjamin Riefenstahl Newsgroups: gmane.emacs.bugs Subject: bug#34685: 26.1; function nnrss-get-namespace-prefix always returns nil Date: Mon, 09 Aug 2021 18:30:01 +0200 Message-ID: <87tujymvhy.fsf@turtle-trading.net> References: <87a7gva5hy.fsf@gmail.com> <877ebza15d.fsf@gmail.com> <87y2yahel4.fsf@gnus.org> <877dgx76x0.fsf@arrian.i-did-not-set--mail-host-address--so-tickle-me> <877dgu6ck6.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16091"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cc: 34685@debbugs.gnu.org, wenbushi , Noam Postavsky To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 09 18:34:30 2021 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 1mD8EP-0003wS-EX for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Aug 2021 18:34:29 +0200 Original-Received: from localhost ([::1]:43254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD8EN-00012i-Tq for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Aug 2021 12:34:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD8B4-00049Z-JH for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2021 12:31:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46090) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mD8B4-0000du-Ac for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2021 12:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mD8B4-0000MG-4z; Mon, 09 Aug 2021 12:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Benjamin Riefenstahl Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bugs@gnus.org Resent-Date: Mon, 09 Aug 2021 16:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34685 X-GNU-PR-Package: emacs,gnus Original-Received: via spool by 34685-submit@debbugs.gnu.org id=B34685.16285266121301 (code B ref 34685); Mon, 09 Aug 2021 16:31:02 +0000 Original-Received: (at 34685) by debbugs.gnu.org; 9 Aug 2021 16:30:12 +0000 Original-Received: from localhost ([127.0.0.1]:57630 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mD8AG-0000Kt-0k for submit@debbugs.gnu.org; Mon, 09 Aug 2021 12:30:12 -0400 Original-Received: from odoacer.turtle-trading.net ([93.241.193.16]:50295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mD8AC-0000Ja-9u for 34685@debbugs.gnu.org; Mon, 09 Aug 2021 12:30:09 -0400 Original-Received: from zenobia.turtle-trading.net ([192.168.2.109]) by odoacer.turtle-trading.net with esmtp (Exim 4.80) (envelope-from ) id 1mD8A5-0001zk-4n; Mon, 09 Aug 2021 18:30:01 +0200 Original-Received: from benny by zenobia.turtle-trading.net with local (Exim 4.92) (envelope-from ) id 1mD8A5-000878-2d; Mon, 09 Aug 2021 18:30:01 +0200 In-Reply-To: <877dgu6ck6.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 09 Aug 2021 14:13:29 +0200") 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:211451 Archived-At: --=-=-= Content-Type: text/plain Hi Lars, > Benjamin Riefenstahl writes: >> LS09LT0tPQpDb250ZW50LVR5cGU6IHRleHQvcGxhaW4KCkhpIExhcnMsCgpMYXJzIEluZ2Vicmln >> dHNlbiB3cml0ZXM6Cj4gSSd2ZSBub3cgZml4ZWQgdGhpcyBtb3JlIGdlbmVyYWxseSBieSBzZWFy Lars Ingebrigtsen writes: > Your message arrived kinda destroyed, but I used my decoder ring: Sorry about that. My laptop does not have email setup correctly, that made things complicated in this case. >> +(defconst test-nnrss-xml >> + '((rss >> + ((version . "2.0") >> + (xmlns:dc . "http://purl.org/dc/elements/1.1/")) >> + (channel >> + ((xmlns:content . "http://purl.org/rss/1.0/modules/content/")))))) > The problem here is that this test XML isn't a valid DOM -- it's a > list of DOMs. A valid DOM would be I originally just copied this from the output of the debugger, so this is what nnrss-get-namespace-prefix gets passed. I just checked, the structure is the result of xml-parse-region, is that supposed to create something that matches the use of dom-search? When I try it on some test XML it does create this same structure again. Test code: (with-temp-buffer (insert " ") (xml-parse-region (point-min) (point-max))) > So if EL is a list of nodes, then it's the caller of > nnrss-get-namespace-prefix here that should be adjusted to pass in the > car of the list instead? Could you try that and see whether that > works? What is passed to nnrss-get-namespace-prefix is also used in other places and the calling function is a bit complicated so I'd rather not change it. I attach another change in nnrss-get-namespace-prefix function instead. I note that your previous work on this bug is the first time that nnrss.el uses functions from dom.el. It maybe should use it more, but that is a project for another day, I would say. > (And send a new patch; I've applied your test (adjusted).) See below. Thanks for your time, benny --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-nnrss-get-namespace-prefix-bug-34685.patch >From f7f9bc841aa9a4b6fd5a3d8dcffd259f01b10591 Mon Sep 17 00:00:00 2001 From: Benjamin Riefenstahl Date: Mon, 9 Aug 2021 18:06:31 +0200 Subject: [PATCH] Fix nnrss-get-namespace-prefix (bug#34685) nnrss-get-namespace-prefix gets passed the result of xml-parse-region and that is not quite what dom-search expects. * lisp/gnus/nnrss.el (nnrss-get-namespace-prefix): Use the car of parameter el to match what dom-search expects. * test/lisp/gnus/nnrss-tests.el (test-nnrss-xml): Adjust to what xml-parse-region produces. --- lisp/gnus/nnrss.el | 7 ++++--- test/lisp/gnus/nnrss-tests.el | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el index 0f12ee0e9d..97c9f18a60 100644 --- a/lisp/gnus/nnrss.el +++ b/lisp/gnus/nnrss.el @@ -954,9 +954,10 @@ nnrss-get-namespace-prefix "Given EL (containing a parsed element) and URI (containing a string that gives the URI for which you want to retrieve the namespace prefix), return the prefix." - (let* ((prefix (car (rassoc uri (dom-attributes - (dom-search - el + (let* ((dom (car el)) + (prefix (car (rassoc uri (dom-attributes + (dom-search + dom (lambda (node) (rassoc uri (dom-attributes node)))))))) (nslist (if prefix diff --git a/test/lisp/gnus/nnrss-tests.el b/test/lisp/gnus/nnrss-tests.el index 01b374a2f6..92b7dacf18 100644 --- a/test/lisp/gnus/nnrss-tests.el +++ b/test/lisp/gnus/nnrss-tests.el @@ -27,11 +27,11 @@ test-nnrss-normalize "Fri, 17 Sep 2004 05:09:49 +0000"))) (defconst test-nnrss-xml - '(rss - ((version . "2.0") - (xmlns:dc . "http://purl.org/dc/elements/1.1/")) - (channel - ((xmlns:content . "http://purl.org/rss/1.0/modules/content/"))))) + '((rss + ((version . "2.0") + (xmlns:dc . "http://purl.org/dc/elements/1.1/")) + (channel + ((xmlns:content . "http://purl.org/rss/1.0/modules/content/")))))) (ert-deftest test-nnrss-namespace-top () (should (equal (nnrss-get-namespace-prefix -- 2.20.1 --=-=-=--