mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Bugfix: picture name suffixes were malformed on export and thus could not be re-imported.
This commit is contained in:
@@ -60,10 +60,15 @@ public class FileUtilsTest extends TestCase {
|
||||
*/
|
||||
public void testSanitizeFileName() {
|
||||
String name = "Swim\10ming-^across:/the/ pacific (ocean).";
|
||||
String expected = "Swim_ming-^across_the_ pacific (ocean)_";
|
||||
String expected = "Swim_ming-^across_the_ pacific (ocean).";
|
||||
assertEquals(expected, FileUtils.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
public void testSanitizeFileNameWithSuffix() {
|
||||
String name = "FileName.jpeg";
|
||||
assertEquals(name, FileUtils.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link FileUtils#sanitizeFileName(String)} with i18n characters (in Chinese and Russian).
|
||||
* Verifies that they are allowed.
|
||||
|
||||
@@ -204,12 +204,13 @@ public class FileUtils {
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
// TODO Check if this function is still needed.
|
||||
public static String sanitizeFileName(String name) {
|
||||
StringBuilder builder = new StringBuilder(name.length());
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
int codePoint = name.codePointAt(i);
|
||||
char character = name.charAt(i);
|
||||
if (Character.isLetterOrDigit(character) || codePoint > 127 || isSpecialFat32(character)) {
|
||||
if (Character.isLetterOrDigit(character) || codePoint > 127 || isSpecialFat32(character) || character == '.') {
|
||||
builder.appendCodePoint(codePoint);
|
||||
} else {
|
||||
builder.append("_");
|
||||
|
||||
Reference in New Issue
Block a user