Skip to content
Snippets Groups Projects
Commit 99fccc32 authored by srosse's avatar srosse
Browse files

OO-3801: trim folder names in WebDAV provider for courses

parent 1571f3e7
No related branches found
No related tags found
No related merge requests found
......@@ -502,7 +502,8 @@ public final class RequestUtil {
default: sb.append(ch);
}
}
return Normalizer.normalize(sb, Normalizer.Form.NFC);
String normalized = Normalizer.normalize(sb, Normalizer.Form.NFC);
return normalized.trim();
}
}
......@@ -19,8 +19,14 @@
*/
package org.olat.core.commons.services.webdav.servlets;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
/**
*
......@@ -28,19 +34,30 @@ import org.junit.Test;
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
@RunWith(Parameterized.class)
public class RequestUtilsTest {
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ "Test", "Test" },
{ "Test\u00E9\u00E4", "Test\u00E9\u00E4" },
{ "%12 ?()_//", "_12 _()___" },
{ " Test ", "Test" }
});
}
private String filename;
private String normalizedFilename;
public RequestUtilsTest(String filename, String normalizedFilename) {
this.filename = filename;
this.normalizedFilename = normalizedFilename;
}
@Test
public void testNormalizeFilename() {
String simpleFilename = RequestUtil.normalizeFilename("Test");
Assert.assertEquals("Test", simpleFilename);
String accentFilename = RequestUtil.normalizeFilename("Test\u00E9\u00E4");
Assert.assertEquals("Test\u00E9\u00E4", accentFilename);
String moreSpecialChars = RequestUtil.normalizeFilename("%12 ?()_//");
Assert.assertEquals("_12 _()___", moreSpecialChars);
String correctedFilename = RequestUtil.normalizeFilename(filename);
Assert.assertEquals(normalizedFilename, correctedFilename);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment