From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24772 invoked from network); 16 Apr 2004 09:14:48 -0000 Received: from unknown (HELO monty-python.gnu.org) (199.232.76.173) by sources.redhat.com with SMTP; 16 Apr 2004 09:14:48 -0000 Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BEPP5-0005vX-Uw for listarch-gnats-devel@sources.redhat.com; Fri, 16 Apr 2004 05:12:55 -0400 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BEPMx-0004H1-RM for help-gnats@gnu.org; Fri, 16 Apr 2004 05:10:43 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BEPM8-00036y-FM for help-gnats@gnu.org; Fri, 16 Apr 2004 05:10:24 -0400 Received: from [193.72.144.2] (helo=mail.elca.ch) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BEPM6-0002un-Qr for help-gnats@gnu.org; Fri, 16 Apr 2004 05:09:51 -0400 Received: from exchange.elca.ch (unverified) by mail.elca.ch (Content Technologies SMTPRS 4.3.10) with ESMTP id ; Fri, 16 Apr 2004 11:09:44 +0200 Received: by exchange.elca.ch with Internet Mail Service (5.5.2653.19) id <235X4Y4H>; Fri, 16 Apr 2004 11:09:39 +0200 Message-ID: From: Dieperink Alwin To: "'help-gnats@gnu.org'" Date: Fri, 16 Apr 2004 17:57:00 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C42392.8BB0E580" Cc: 'Yngve Svendsen' Subject: Gnatsweb: stripping empty fields in URLs X-BeenThere: help-gnats@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: General discussion about GNU GNATS List-Archive: List-Post: List-Help: List-Subscribe: , Sender: help-gnats-bounces+listarch-gnats-devel=sources.redhat.com@gnu.org Errors-To: help-gnats-bounces+listarch-gnats-devel=sources.redhat.com@gnu.org X-SW-Source: 2004-q2/txt/msg00050.txt.bz2 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C42392.8BB0E580 Content-Type: text/plain; charset="ISO-8859-1" Content-length: 686 Hello, As explained in gnatsweb.pl, the size of the query string is limited by the browser to approx. 2K. That's why we want to strip the empty parameters. This patch brings following changes to this: - correct a bug where the striping was incorrect - added a function to do the striping - use that function everywhere, even where the striping was not done yet With these changes, the URLs are now correct and as short as possible, even in the return_url parameter. This patch also removes the ability to store a query when the displayed result is already the result of a stored query. This also leads to longer query strings and could make the cookie unusable. Regards -- Alwin ------_=_NextPart_000_01C42392.8BB0E580 Content-Type: application/octet-stream; name="strip_empty_params.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="strip_empty_params.patch" Content-length: 5846 --- gnatsweb_v40.pl Thu Apr 15 20:42:03 2004=0A= +++ gnatsweb.pl Fri Apr 16 11:50:23 2004=0A= @@ -1313,7 +1313,7 @@=0A= my($cmd, $pr, $include_return_url) =3D @_;=0A= my $url =3D $q->url() . "?cmd=3D$cmd&database=3D$global_prefs{'database'= }";=0A= $url .=3D "&pr=3D$pr" if $pr;=0A= - $url .=3D "&return_url=3D" . $q->escape($q->self_url())=0A= + $url .=3D "&return_url=3D" . $q->escape(strip_empty_params($q->self_url(= )))=0A= if $include_return_url;=0A= return $url;=0A= }=0A= @@ -2388,6 +2388,7 @@=0A= my(@query_results) =3D @_;=0A= my $displaydate =3D $q->param('displaydate');=0A= my $reversesort =3D $q->param('reversesort');=0A= + my $queryname =3D $q->param('queryname');=0A= =0A= my $num_matches =3D scalar(@query_results);=0A= my $heading =3D sprintf("%s %s found",=0A= @@ -2421,11 +2422,7 @@=0A= }=0A= $whichfield++;=0A= =0A= - # strip empty params out of self_url(). in a gnats db with many=0A= - # fields, the url query-string will become very long. this is a=0A= - # problem, since IE5 truncates query-strings at ~2048 characters.=0A= - my ($query_string) =3D $q->self_url() =3D~ m/^[^?]*\?(.*)$/;=0A= - $query_string =3D~ s/(\w|-)+=3D;//g;=0A= + my ($query_string) =3D strip_empty_params($q->self_url() =3D~ m/^[^?]*= \?(.*)$/);=0A= =0A= my $href =3D $script_name . '?' . $query_string;=0A= print "\n$_\n";=0A= @@ -2506,11 +2503,7 @@=0A= $q->end_form();=0A= =0A= # Provide a URL which someone can use to bookmark this query.=0A= - my $url =3D $q->self_url();=0A= - # strip empty params out of $url. in a gnats db with many=0A= - # fields, the url query-string will become very long. this is a=0A= - # problem, since IE5 truncates query-strings at ~2048 characters.=0A= - $url =3D~ s/(\w|-)+=3D;//g;=0A= + my $url =3D strip_empty_params($q->self_url());=0A= =0A= print "\n

",=0A= qq{View for bookmarking},=0A= @@ -2523,27 +2516,31 @@=0A= print qq{Reverse sort order},=0A= "

";=0A= =0A= - # Allow the user to store this query. Need to repeat params as hidden= =0A= - # fields so they are available to the 'store query' handler.=0A= - print $q->start_form(), hidden_debug();=0A= - foreach ($q->param())=0A= - {=0A= - # Ignore certain params.=0A= - next if /^(cmd|queryname)$/;=0A= - print $q->hidden($_), "\n";=0A= - }=0A= - print "\n\n",=0A= - "\n",=0A= - "\n",=0A= - "\n\n\n
Remember this query as:",=0A= - $q->textfield(-name=3D>'queryname', -size=3D>25),=0A= - "";=0A= - # Note: include hidden 'cmd' so user can simply press Enter w/o clicking= .=0A= - print $q->hidden(-name=3D>'cmd', -value=3D>'store query', -override=3D>1= ),=0A= - $q->submit('cmd', 'store query'),=0A= - $q->hidden('return_url', $q->self_url()),=0A= - "\n
",=0A= - $q->end_form();=0A= + if (!$queryname)=0A= + {=0A= + # Allow the user to store this query. Need to repeat params as hidden= =0A= + # fields so they are available to the 'store query' handler.=0A= + print $q->start_form(), hidden_debug();=0A= + foreach ($q->param())=0A= + {=0A= + # Ignore certain params.=0A= + next if /^(cmd|queryname)$/;=0A= + print $q->hidden($_), "\n";=0A= + }=0A= + print "\n\n",=0A= + "\n",=0A= + "\n",=0A= + "\n\n\n
Remember this query as:",=0A= + $q->textfield(-name=3D>'queryname', -size=3D>25),=0A= + "";=0A= + # Note: include hidden 'cmd' so user can simply press Enter w/o clicki= ng.=0A= +=0A= + print $q->hidden(-name=3D>'cmd', -value=3D>'store query', -override=3D= >1),=0A= + $q->submit('cmd', 'store query'),=0A= + $q->hidden('return_url', strip_empty_params($q->self_url())),=0A= + "\n
",=0A= + $q->end_form();=0A= + }=0A= }=0A= =0A= # store_query -=0A= @@ -2581,12 +2578,7 @@=0A= =0A= # Don't save certain params.=0A= $q->delete('cmd');=0A= - my $query_string =3D $q->query_string();=0A= -=0A= - # strip empty params out of $query_string. in a gnats db with many=0A= - # fields, the query-string will become very long, and may exceed the=0A= - # 4K limit for cookies.=0A= - $query_string =3D~ s/\w+=3D;//g;=0A= + my $query_string =3D strip_empty_params($q->query_string());=0A= =0A= if (length($query_string . $global_cookie_path . "gnatsweb-query-$queryn= ame") > 4050) {=0A= # this cookie is going to be longer than 4K, so we'll have to punt=0A= @@ -2674,7 +2666,7 @@=0A= $q->start_form(),=0A= hidden_debug(),=0A= "",=0A= - $q->hidden('return_url', $q->self_url()),=0A= + $q->hidden('return_url', strip_empty_params($q->self_url())),=0A= hidden_db(),=0A= $q->submit('cmd', 'delete stored query'),=0A= " ",=0A= @@ -2907,6 +2899,16 @@=0A= return ($LEVEL_TO_CODE{$access_level} >=3D $LEVEL_TO_CODE{'edit'});=0A= }=0A= =0A= +# strip empty params out of url(). in a gnats db with many=0A= +# fields, the url query-string will become very long. this is a=0A= +# problem, since IE5 truncates query-strings at ~2048 characters.=0A= +sub strip_empty_params=0A= + {=0A= + my ($url) =3D @_;=0A= + $url =3D~ s/(\w|-)+=3D;//g;=0A= + return $url;=0A= + }=0A= +=0A= sub main_page=0A= {=0A= my $page =3D 'Main';=0A= @@ -4158,7 +4160,7 @@=0A= # We don't have username/database; give login page then=0A= # redirect to the url they really want (self_url).=0A= print_header();=0A= - login_page($q->self_url());=0A= + login_page(strip_empty_params($q->self_url()));=0A= exit();=0A= }=0A= ------_=_NextPart_000_01C42392.8BB0E580 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 139 _______________________________________________ Help-gnats mailing list Help-gnats@gnu.org http://mail.gnu.org/mailman/listinfo/help-gnats ------_=_NextPart_000_01C42392.8BB0E580--