mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
@@ -20,6 +20,8 @@ namespace Orchard.MediaLibrary.Services {
|
|||||||
private readonly IStorageProvider _storageProvider;
|
private readonly IStorageProvider _storageProvider;
|
||||||
private readonly IEnumerable<IMediaFactorySelector> _mediaFactorySelectors;
|
private readonly IEnumerable<IMediaFactorySelector> _mediaFactorySelectors;
|
||||||
|
|
||||||
|
private static char[] HttpUnallowed = new char[] { '<', '>', '*', '%', '&', ':', '\\', '?' };
|
||||||
|
|
||||||
public MediaLibraryService(
|
public MediaLibraryService(
|
||||||
IOrchardServices orchardServices,
|
IOrchardServices orchardServices,
|
||||||
IMimeTypeProvider mimeTypeProvider,
|
IMimeTypeProvider mimeTypeProvider,
|
||||||
@@ -120,6 +122,12 @@ namespace Orchard.MediaLibrary.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string GetUniqueFilename(string folderPath, string filename) {
|
public string GetUniqueFilename(string folderPath, string filename) {
|
||||||
|
|
||||||
|
// remove any char which is unallowed in an HTTP request
|
||||||
|
foreach (var unallowedChar in HttpUnallowed) {
|
||||||
|
filename = filename.Replace(unallowedChar.ToString(), "");
|
||||||
|
}
|
||||||
|
|
||||||
// compute a unique filename
|
// compute a unique filename
|
||||||
var uniqueFilename = filename;
|
var uniqueFilename = filename;
|
||||||
var index = 1;
|
var index = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user