From: Jonathan Nieder <jrnieder@gmail.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"J.H." <warthog9@kernel.org>,
git@vger.kernel.org, "Petr Baudis" <pasky@ucw.cz>
Subject: [PATCH] gitweb: do misparse nonnumeric content tag files that contain a digit
Date: Thu, 9 Jun 2011 02:08:57 -0500 [thread overview]
Message-ID: <20110609070857.GA735@elie> (raw)
In-Reply-To: <201103071900.16126.jnareb@gmail.com>
v1.7.6-rc0~27^2~4 (gitweb: Change the way "content tags" ('ctags') are
handled, 2011-04-29) tried to make gitweb's tag cloud feature more
intuitive for webmasters by checking whether the ctags/<label> under
a project's .git dir contains a number (representing the strength of
association to <label>) before treating it as one.
So after that change, after putting '$feature{'ctags'}{'default'} =
[1];' in your $GITWEB_CONFIG, you could do
echo Linux >.git/ctags/linux
and gitweb would treat that as a request to tag the current repository
with the Linux tag, instead of the previous behavior of writing an
error page embedded in the projects list that triggers error messages
from Chromium and Firefox about malformed XML.
Unfortunately the pattern (\d+) used to match numbers is too loose,
and the "XML declaration allowed only at the start of the document"
error can still be experienced if you write "Linux-2.6" in place of
"Linux" in the example above. Fix it by tightening the pattern to
^\d+$.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi,
Jakub Narebski wrote:
>> On Thu, Mar 03, 2011 at 01:42:15AM +0100, Jakub Narebski wrote:
>>> 1. Hardening parsing of ctags files, so that gitweb does not crash on
>>> malformed entries, but e.g. just ignores them.
>
> Done.
Sorry for a (long-) delayed response. Based on testing rc0 today, it
works well; thanks! Patch to fix a small detail noticed while trying
'-1' follows.
gitweb/gitweb.perl | 2 +-
t/t9500-gitweb-standalone-no-errors.sh | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ebf2d1c..1b83a8d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2644,7 +2644,7 @@ sub git_get_project_ctags {
close $ct;
(my $ctag = $tagfile) =~ s#.*/##;
- if ($val =~ /\d+/) {
+ if ($val =~ /^\d+$/) {
$ctags->{$ctag} = $val;
} else {
$ctags->{$ctag} = 1;
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index f5648a6..5329715 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -644,6 +644,14 @@ test_expect_success \
'ctags: search projects by non existent tag' \
'gitweb_run "by_tag=non-existent"'
+test_expect_success \
+ 'ctags: malformed tag weights' \
+ 'mkdir -p .git/ctags &&
+ echo "not-a-number" > .git/ctags/nan &&
+ echo "not-a-number-2" > .git/ctags/nan2 &&
+ echo "0.1" >.git/ctags/floating-point &&
+ gitweb_run'
+
# ----------------------------------------------------------------------
# categories
--
1.7.6.rc0
next prev parent reply other threads:[~2011-06-09 7:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20110301190229.11297.17767.reportbug@cassiopeia.kleinek>
2011-03-01 22:21 ` gitweb: cloud tags feature produces malformed XML for errors Jonathan Nieder
2011-03-02 0:05 ` Jakub Narebski
2011-03-02 8:24 ` Jakub Narebski
2011-03-02 8:45 ` Uwe Kleine-König
2011-03-02 1:06 ` J.H.
2011-03-02 21:18 ` Jakub Narebski
2011-03-02 21:55 ` Uwe Kleine-König
2011-03-03 0:42 ` Jakub Narebski
2011-03-03 8:19 ` Uwe Kleine-König
2011-03-07 18:00 ` [RFC/PATCH] gitweb: Change the way "content tags" ('ctags') are handled Jakub Narebski
2011-03-09 14:04 ` [PATCH 2/1] gitweb: Mark matched 'ctag' / contents tag (?by_tag=foo) Jakub Narebski
2011-03-09 14:09 ` Petr Baudis
2011-06-09 7:08 ` Jonathan Nieder [this message]
2011-06-09 7:11 ` [PATCH] gitweb: do misparse nonnumeric content tag files that contain a digit Jonathan Nieder
2011-03-03 11:58 ` gitweb: cloud tags feature produces malformed XML for errors Petr Baudis
2011-03-03 13:29 ` Jakub Narebski
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110609070857.GA735@elie \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
--cc=pasky@ucw.cz \
--cc=u.kleine-koenig@pengutronix.de \
--cc=warthog9@kernel.org \
/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.
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 NNTP newsgroup(s).