{"thread":{"id":"5589","subject":"[PATCH] gitweb fix validating pg (page) parameter","startedAt":"2006-09-17T11:52:45Z","lastAt":"2006-09-17T21:45:32Z","messageCount":4,"participants":["Matthias Lederhofer","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27071","messageId":"20060917115245.GA15658@moooo.ath.cx","threadId":"5589","inReplyTo":null,"subject":"[PATCH] gitweb fix validating pg (page) parameter","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-17T11:52:45Z","receivedAt":"2006-09-17T11:52:45Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Currently it is possible to give any string ending with a number as\npage.  -1 for example is quite bad (error log shows probably 100\nwarnings).\n---\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 497129a..346c15c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -259,7 +259,7 @@ if (defined $hash_parent_base) {\n \n our $page = $cgi->param('pg');\n if (defined $page) {\n-\tif ($page =~ m/[^0-9]$/) {\n+\tif ($page =~ m/[^0-9]/) {\n \t\tdie_error(undef, \"Invalid page parameter\");\n \t}\n }\n-- \n1.4.2.1.ge767\n"},{"id":"27090","messageId":"7vlkoi2nqr.fsf@assigned-by-dhcp.cox.net","threadId":"5589","inReplyTo":"20060917115245.GA15658@moooo.ath.cx","subject":"Re: [PATCH] gitweb fix validating pg (page) parameter","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T21:21:16Z","receivedAt":"2006-09-17T21:21:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> Currently it is possible to give any string ending with a number as\n> page.  -1 for example is quite bad (error log shows probably 100\n> warnings).\n>\n> @@ -259,7 +259,7 @@ if (defined $hash_parent_base) {\n>  \n>  our $page = $cgi->param('pg');\n>  if (defined $page) {\n> -\tif ($page =~ m/[^0-9]$/) {\n> +\tif ($page =~ m/[^0-9]/) {\n>  \t\tdie_error(undef, \"Invalid page parameter\");\n>  \t}\n>  }\n\nAre we complaining if $page is not a validly formatted number\nhere?  If so why not\n\n\tunless ($page =~ /^\\d+$/ && 1 <= $page) {\n        \tbarf(...);\n\t}\n\n???\n"},{"id":"27092","messageId":"20060917213838.GA12782@moooo.ath.cx","threadId":"5589","inReplyTo":"7vlkoi2nqr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb fix validating pg (page) parameter","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-17T21:38:38Z","receivedAt":"2006-09-17T21:38:38Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Matthias Lederhofer <matled@gmx.net> writes:\n> \n> > Currently it is possible to give any string ending with a number as\n> > page.  -1 for example is quite bad (error log shows probably 100\n> > warnings).\n> >\n> > @@ -259,7 +259,7 @@ if (defined $hash_parent_base) {\n> >  \n> >  our $page = $cgi->param('pg');\n> >  if (defined $page) {\n> > -\tif ($page =~ m/[^0-9]$/) {\n> > +\tif ($page =~ m/[^0-9]/) {\n> >  \t\tdie_error(undef, \"Invalid page parameter\");\n> >  \t}\n> >  }\n> \n> Are we complaining if $page is not a validly formatted number\n> here?  If so why not\n> \n> \tunless ($page =~ /^\\d+$/ && 1 <= $page) {\n>         \tbarf(...);\n> \t}\nThe first page seems to have number 0.  After removing the 1 <= $page\nthis code should do the same as my patch, apply whatever you think is\neasier to read (I prefer if over unless most of the time).\n"},{"id":"27093","messageId":"7v8xki2mmb.fsf@assigned-by-dhcp.cox.net","threadId":"5589","inReplyTo":"20060917213838.GA12782@moooo.ath.cx","subject":"Re: [PATCH] gitweb fix validating pg (page) parameter","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T21:45:32Z","receivedAt":"2006-09-17T21:45:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n>> > +\tif ($page =~ m/[^0-9]/) {\n>...\n> The first page seems to have number 0.  After removing the 1 <= $page\n> this code should do the same as my patch, apply whatever you think is\n> easier to read (I prefer if over unless most of the time).\n\nAh, I did not notice we call the first page 0; barfing on any\nnon-digit in the string like you do sounds quite sane.\n\nThanks.\n"}]}