[v3,3/4] proxy.cgi: strip newline from subnet parameters

Message ID 20180214193522.26880-4-berny156@gmx.de
State Dropped
Headers
Series proxy.cgi fixes for bugzilla #10852 |

Commit Message

Bernhard Held Feb. 15, 2018, 6:35 a.m. UTC
  The subnets in @templist end with newlines. Theses have to be removed
before printing and comparison with other subnets.
---
 html/cgi-bin/proxy.cgi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Bernhard Bitsch Feb. 15, 2018, 10:14 a.m. UTC | #1
Hi,

newlines have to be stripped from each line.
Therefore the code should read:
  				close(SUBNETS);
 			}
  
  			foreach (@templist)
  			{
			        chomp;
  				@temp = split(/\//);

- Bernhard

> Gesendet: Mittwoch, 14. Februar 2018 um 20:35 Uhr
> Von: "Bernhard Held" <berny156@gmx.de>
> An: development@lists.ipfire.org
> Betreff: [PATCH v3 3/4] proxy.cgi: strip newline from subnet parameters
>
> The subnets in @templist end with newlines. Theses have to be removed
> before printing and comparison with other subnets.
> ---
>  html/cgi-bin/proxy.cgi | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi
> index 6aa14e15a..d565ffbdc 100644
> --- a/html/cgi-bin/proxy.cgi
> +++ b/html/cgi-bin/proxy.cgi
> @@ -3061,6 +3061,8 @@ END
>  				close(SUBNETS);
>  			}
>  
> +			chomp(@templist);
> +
>  			foreach (@templist)
>  			{
>  				@temp = split(/\//);
> @@ -3069,7 +3071,6 @@ END
>  					($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
>  					)
>  				{
> -					chomp $temp[1];
>  					print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
>  				}
>  			}
> -- 
> 2.16.1
> 
>
  
Bernhard Held Feb. 15, 2018, 5:38 p.m. UTC | #2
> Bernhard Bitsch <Bernhard.Bitsch@gmx.de> hat am 15. Februar 2018 um 00:14 geschrieben:
> newlines have to be stripped from each line.
> Therefore the code should read:
>   				close(SUBNETS);
>  			}
>   
>   			foreach (@templist)
>   			{
> 			        chomp;
>   				@temp = split(/\//);

Hm, I see now that I misinterpreted your last comment regarding this patch.

However, v3 is still correct, because if you chomp a list, each element is chomped.

Regards,
Bernhard

> - Bernhard
> 
> > Gesendet: Mittwoch, 14. Februar 2018 um 20:35 Uhr
> > Von: "Bernhard Held" <berny156@gmx.de>
> > An: development@lists.ipfire.org
> > Betreff: [PATCH v3 3/4] proxy.cgi: strip newline from subnet parameters
> >
> > The subnets in @templist end with newlines. Theses have to be removed
> > before printing and comparison with other subnets.
> > ---
> >  html/cgi-bin/proxy.cgi | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi
> > index 6aa14e15a..d565ffbdc 100644
> > --- a/html/cgi-bin/proxy.cgi
> > +++ b/html/cgi-bin/proxy.cgi
> > @@ -3061,6 +3061,8 @@ END
> >  				close(SUBNETS);
> >  			}
> >  
> > +			chomp(@templist);
> > +
> >  			foreach (@templist)
> >  			{
> >  				@temp = split(/\//);
> > @@ -3069,7 +3071,6 @@ END
> >  					($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
> >  					)
> >  				{
> > -					chomp $temp[1];
> >  					print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
> >  				}
> >  			}
> > -- 
> > 2.16.1
> > 
> >
  

Patch

diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi
index 6aa14e15a..d565ffbdc 100644
--- a/html/cgi-bin/proxy.cgi
+++ b/html/cgi-bin/proxy.cgi
@@ -3061,6 +3061,8 @@  END
 				close(SUBNETS);
 			}
 
+			chomp(@templist);
+
 			foreach (@templist)
 			{
 				@temp = split(/\//);
@@ -3069,7 +3071,6 @@  END
 					($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
 					)
 				{
-					chomp $temp[1];
 					print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
 				}
 			}