diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index befc56d244..965cc43815 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -340,7 +340,7 @@ namespace osu.Game.Beatmaps
static string createBeatmapFilenameFromMetadata(BeatmapInfo beatmapInfo)
{
var metadata = beatmapInfo.Metadata;
- return $"{metadata.Artist} - {metadata.Title} ({metadata.Author.Username}) [{beatmapInfo.DifficultyName}].osu".GetValidArchiveContentFilename();
+ return $"{metadata.Artist} - {metadata.Title} ({metadata.Author.Username}) [{beatmapInfo.DifficultyName}].osu".GetValidFilename();
}
}
diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs
index d9fdc40abc..16d7441dde 100644
--- a/osu.Game/Database/LegacyExporter.cs
+++ b/osu.Game/Database/LegacyExporter.cs
@@ -37,7 +37,7 @@ namespace osu.Game.Database
/// The item to export.
public void Export(TModel item)
{
- string filename = $"{item.GetDisplayString().GetValidArchiveContentFilename()}{FileExtension}";
+ string filename = $"{item.GetDisplayString().GetValidFilename()}{FileExtension}";
using (var stream = exportStorage.CreateFileSafely(filename))
ExportModelTo(item, stream);
diff --git a/osu.Game/Extensions/ModelExtensions.cs b/osu.Game/Extensions/ModelExtensions.cs
index f8db5f4e88..efb3c4d633 100644
--- a/osu.Game/Extensions/ModelExtensions.cs
+++ b/osu.Game/Extensions/ModelExtensions.cs
@@ -15,6 +15,8 @@ namespace osu.Game.Extensions
{
public static class ModelExtensions
{
+ private static readonly Regex invalid_filename_chars = new Regex(@"(?!$)[^A-Za-z0-9_()[\]. \-]", RegexOptions.Compiled);
+
///
/// Get the relative path in osu! storage for this file.
///
@@ -137,14 +139,14 @@ namespace osu.Game.Extensions
return instance.OnlineID.Equals(other.OnlineID);
}
- private static readonly Regex invalid_filename_chars = new Regex(@"(?!$)[^A-Za-z0-9_()[\]. \-]", RegexOptions.Compiled);
-
///
- /// Get a valid filename for use inside a zip file. Avoids backslashes being incorrectly converted to directories.
+ /// Create a valid filename which should work across all platforms.
///
- public static string GetValidArchiveContentFilename(this string filename)
- {
- return invalid_filename_chars.Replace(filename, "_");
- }
+ ///
+ /// This function replaces all characters not included in a very pessimistic list which should be compatible
+ /// across all operating systems. We are using this in place of as
+ /// that function does not have per-platform considerations (and is only made to work on windows).
+ ///
+ public static string GetValidFilename(this string filename) => invalid_filename_chars.Replace(filename, "_");
}
}