mirror of https://github.com/apache/archiva.git
[MRM-1972] Adding additional encoding for name value
(cherry picked from commit 8e5fdd4536
)
This commit is contained in:
parent
6160966fa0
commit
2ade46ab20
|
@ -31,6 +31,8 @@ import org.apache.archiva.configuration.Configuration;
|
|||
import org.apache.archiva.configuration.UserInterfaceOptions;
|
||||
import org.apache.archiva.configuration.WebappConfiguration;
|
||||
import org.apache.archiva.metadata.model.facets.AuditEvent;
|
||||
import org.apache.commons.codec.net.URLCodec;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.maven.wagon.providers.http.HttpWagon;
|
||||
|
@ -336,6 +338,10 @@ public class DefaultArchivaAdministration
|
|||
|
||||
}
|
||||
|
||||
private String convertName(String name) {
|
||||
return StringEscapeUtils.escapeHtml( StringUtils.trimToEmpty( name ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrganisationInformation( OrganisationInformation organisationInformation )
|
||||
throws RepositoryAdminException
|
||||
|
@ -345,6 +351,7 @@ public class DefaultArchivaAdministration
|
|||
Configuration configuration = getArchivaConfiguration( ).getConfiguration( );
|
||||
if ( organisationInformation != null )
|
||||
{
|
||||
organisationInformation.setName( convertName( organisationInformation.getName() ));
|
||||
org.apache.archiva.configuration.OrganisationInformation organisationInformationModel =
|
||||
getModelMapper( ).map( organisationInformation,
|
||||
org.apache.archiva.configuration.OrganisationInformation.class );
|
||||
|
|
|
@ -253,6 +253,23 @@ public class ArchivaAdministrationTest
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void badOrganisationName( )
|
||||
{
|
||||
try
|
||||
{
|
||||
OrganisationInformation newOrganisationInformation = new OrganisationInformation( );
|
||||
newOrganisationInformation.setName( "/><svg/onload=alert(/url_xss/)>Test Org\"" );
|
||||
archivaAdministration.setOrganisationInformation( newOrganisationInformation );
|
||||
assertEquals("/><svg/onload=alert(/url_xss/)>Test Org"", archivaAdministration.getOrganisationInformation().getName());
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
// OK
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uiConfiguration()
|
||||
throws Exception
|
||||
|
|
Loading…
Reference in New Issue