From 2de246045762c6224acdc49042a69a5a4d522f96 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 4 Oct 2011 13:59:23 +0000 Subject: [PATCH] [MRM-1173] Cannot delete patterns with single and double quotes : fix black list too simplify too fix for MRM-1135 git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1178795 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractProxyConnectorFormAction.java | 52 ++++--------------- .../proxy/EditProxyConnectorAction.java | 8 --- .../jsp/admin/include/proxyConnectorForm.jspf | 14 ++--- 3 files changed, 17 insertions(+), 57 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java index 19d454eb0..fc8dd0c80 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java @@ -28,6 +28,7 @@ import org.apache.archiva.policies.DownloadErrorPolicy; import org.apache.archiva.policies.Policy; import org.apache.archiva.policies.PostDownloadPolicy; import org.apache.archiva.policies.PreDownloadPolicy; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import javax.annotation.PostConstruct; @@ -110,45 +111,12 @@ public abstract class AbstractProxyConnectorFormAction this.downloadErrorPolicyMap = getBeansOfType( DownloadErrorPolicy.class ); } - protected List escapePatterns( List patterns ) - { - List escapedPatterns = new ArrayList( ); - if ( patterns != null ) - { - for ( String pattern : patterns ) - { - String escapedPattern = StringUtils.replace( pattern, "\\", "\\\\" ); - escapedPatterns.add( escapedPattern ); - } - } - - return escapedPatterns; - } - - protected List unescapePatterns( List patterns ) - { - List rawPatterns = new ArrayList( ); - if ( patterns != null ) - { - for ( String pattern : patterns ) - { - String unescapedPattern = StringUtils.replace( pattern, "\\\\", "\\" ); - rawPatterns.add( unescapedPattern ); - } - } - - return rawPatterns; - } - - private String escapePattern( String pattern ) - { - return StringUtils.replace( pattern, "\\", "\\\\" ); - } - public String addBlackListPattern( ) { String pattern = getBlackListPattern( ); + //pattern = StringEscapeUtils.unescapeJavaScript( pattern ); + if ( StringUtils.isBlank( pattern ) ) { addActionError( "Cannot add a blank black list pattern." ); @@ -156,7 +124,7 @@ public abstract class AbstractProxyConnectorFormAction if ( !hasActionErrors( ) ) { - getConnector( ).getBlackListPatterns( ).add( escapePattern( pattern ) ); + getConnector( ).getBlackListPatterns( ).add( pattern ); setBlackListPattern( null ); } @@ -192,7 +160,7 @@ public abstract class AbstractProxyConnectorFormAction public String addWhiteListPattern( ) { String pattern = getWhiteListPattern( ); - + //pattern = StringEscapeUtils.unescapeJavaScript( pattern ); if ( StringUtils.isBlank( pattern ) ) { addActionError( "Cannot add a blank white list pattern." ); @@ -200,7 +168,7 @@ public abstract class AbstractProxyConnectorFormAction if ( !hasActionErrors( ) ) { - getConnector( ).getWhiteListPatterns( ).add( escapePattern( pattern ) ); + getConnector( ).getWhiteListPatterns( ).add( pattern ); setWhiteListPattern( null ); } @@ -276,14 +244,14 @@ public abstract class AbstractProxyConnectorFormAction } if ( !getConnector( ).getBlackListPatterns( ).contains( pattern ) - && !getConnector( ).getBlackListPatterns( ).contains( StringUtils.replace( pattern, "\\", "\\\\" ) ) ) + && !getConnector( ).getBlackListPatterns( ).contains( pattern )) { addActionError( "Non-existant black list pattern [" + pattern + "], no black list pattern removed." ); } if ( !hasActionErrors( ) ) { - getConnector( ).getBlackListPatterns( ).remove( escapePattern( pattern ) ); + getConnector( ).getBlackListPatterns( ).remove( pattern ); } setBlackListPattern( null ); @@ -327,14 +295,14 @@ public abstract class AbstractProxyConnectorFormAction } if ( !getConnector( ).getWhiteListPatterns( ).contains( pattern ) - && !getConnector( ).getWhiteListPatterns( ).contains( StringUtils.replace( pattern, "\\", "\\\\" ) ) ) + && !getConnector( ).getWhiteListPatterns( ).contains( pattern )) { addActionError( "Non-existant white list pattern [" + pattern + "], no white list pattern removed." ); } if ( !hasActionErrors( ) ) { - getConnector( ).getWhiteListPatterns( ).remove( escapePattern( pattern ) ); + getConnector( ).getWhiteListPatterns( ).remove( pattern ); } setWhiteListPattern( null ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java index e3d600334..1a9823e1e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java @@ -62,14 +62,6 @@ public class EditProxyConnectorAction + "]" ); return ERROR; } - - if ( connector != null ) - { - // MRM-1135 - connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) ); - connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) ); - } - return INPUT; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf index dc06b416f..979815805 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf @@ -134,19 +134,19 @@ - + - +
- - "${pattern}" + "/> + "${currentPattern}" - + ', 'removeBlackListPattern')">
@@ -176,7 +176,7 @@ - + "/> "${currentPattern}"