This project is read-only.


ImageProfileManager_disallowed declared as @literal but still includes escape seq.'s


In Orchard.MediaProcessing.Services.ImageProfileManager this:
private static readonly char[] _disallowed = @"/:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%".ToCharArray();
is an already literal string containing escape sequences, therefore should be something like:
private static readonly char[] _disallowed = @"/\:?#[]@!$&'()*+,.;=""<>|% ".ToCharArray();
In its current form, the letter "s" is considered disallowed.


sebastienros wrote Sep 27, 2013 at 5:41 PM

You are right, it's a copy pate from a previous regular expression and it's wrong ... fixing right now.

sebastienros wrote Sep 27, 2013 at 6:13 PM

Fixed in changeset d0dd41bb17a410c5f4ea1f3b47569239f74d7ded

anoordende wrote Sep 27, 2013 at 6:14 PM

Thanks, it did smell a bit like regex indeed. Couldn't help myself refactoring for the sake of refactoring though (see :
        private static string CreateDefaultFileName(string path) {
            var ext = Path.GetExtension(path);
            return string.Concat(new string(path.ToCharArray(0, path.LastIndexOf(ext))
                .Select(t => (@"/\:?#[]@!$&'()*+,.;=""<>|% ").ToCharArray().Contains(t) ? '_' : t)
                .ToArray()).RemoveDiacritics(), ext);
Up to you how you wish to implement this sir. As per [discussion:402143] I have been close-up with the media features this week.