#20078: Fixing international characters loss in media profiles

Work Item: 20078
This commit is contained in:
Sebastien Ros
2013-09-09 13:20:41 -07:00
parent a41bd67800
commit 8ef54ff18f
5 changed files with 59 additions and 25 deletions

View File

@@ -197,11 +197,20 @@ namespace Orchard.MediaProcessing.Services {
return false;
}
private static readonly char[] _disallowed = @"/:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%".ToCharArray();
private static string CreateDefaultFileName(string path) {
var extention = Path.GetExtension(path);
var newPath = Path.ChangeExtension(path, "");
newPath = newPath.Replace(@"/", "_");
return newPath.ToSafeName() + extention;
newPath = newPath.TrimEnd('.').RemoveDiacritics();
var normalized = newPath.ToCharArray();
for (var i = 0; i < normalized.Length; i++) {
if (Array.IndexOf(_disallowed, normalized[i]) >= 0) {
normalized[i] = '_';
}
}
return new string(normalized) + extention;
}
}
}