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;
this.downloadErrorPolicyMap = getBeansOfType( DownloadErrorPolicy.class );
}
- protected List<String> escapePatterns( List<String> patterns )
- {
- List<String> escapedPatterns = new ArrayList<String>( );
- if ( patterns != null )
- {
- for ( String pattern : patterns )
- {
- String escapedPattern = StringUtils.replace( pattern, "\\", "\\\\" );
- escapedPatterns.add( escapedPattern );
- }
- }
-
- return escapedPatterns;
- }
-
- protected List<String> unescapePatterns( List<String> patterns )
- {
- List<String> rawPatterns = new ArrayList<String>( );
- 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." );
if ( !hasActionErrors( ) )
{
- getConnector( ).getBlackListPatterns( ).add( escapePattern( pattern ) );
+ getConnector( ).getBlackListPatterns( ).add( pattern );
setBlackListPattern( null );
}
public String addWhiteListPattern( )
{
String pattern = getWhiteListPattern( );
-
+ //pattern = StringEscapeUtils.unescapeJavaScript( pattern );
if ( StringUtils.isBlank( pattern ) )
{
addActionError( "Cannot add a blank white list pattern." );
if ( !hasActionErrors( ) )
{
- getConnector( ).getWhiteListPatterns( ).add( escapePattern( pattern ) );
+ getConnector( ).getWhiteListPatterns( ).add( pattern );
setWhiteListPattern( null );
}
}
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 );
}
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 );
</c:when>
<c:otherwise>
<table>
- <c:forEach items="${connector.blackListPatterns}" var="pattern" varStatus="i">
+ <s:iterator value="connector.blackListPatterns" var="currentPattern" status="i">
<tr>
<td>
- <s:hidden name="connector.blackListPatterns" value="%{#attr.pattern}"/>
- <code>"${pattern}"</code>
+ <input type="hidden" name="connector.blackListPatterns" value="<s:property value="currentPattern" escapeHtml="true"/>"/>
+ <code>"${currentPattern}"</code>
</td>
<td>
- <a href="#" title="Remove [${pattern}] Pattern"
- onclick="setAndSubmit('pattern', '${pattern}', 'removeBlackListPattern')">
+ <a href="#" title="Remove [${currentPattern}] Pattern"
+ onclick="setAndSubmit('pattern', '<s:property value="currentPattern" escapeJavaScript="true"/>', 'removeBlackListPattern')">
<img src="${iconDeleteUrl}"/></a>
</td>
</tr>
- </c:forEach>
+ </s:iterator>
</table>
</c:otherwise>
</c:choose>
<s:iterator value="connector.whiteListPatterns" var="currentPattern" status="i">
<tr>
<td>
- <input type="hidden" name="connector.whiteListPatterns" value="${currentPattern}"/>
+ <input type="hidden" name="connector.whiteListPatterns" value="<s:property value="currentPattern" escapeHtml="true"/>"/>
<code>"${currentPattern}"</code>
</td>
<td>