aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-02-06 20:31:53 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-02-06 20:31:53 -0500
commit57c92fa948bdcefa6b224094ca21f04a8cde6737 (patch)
treec242e21ecea8b04f7c804496bb35a15b90453643
parent65903c56de4247ec8b45b204fc4816ff3db95d96 (diff)
trim trailing slashes from path substitutions
-rw-r--r--MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs
index 5ae3af5e2..db839a66e 100644
--- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -96,10 +96,36 @@ namespace MediaBrowser.Server.Implementations.Configuration
ValidateItemByNamePath(newConfig);
ValidateTranscodingTempPath(newConfig);
+ ValidatePathSubstitutions(newConfig);
base.ReplaceConfiguration(newConfiguration);
}
+ private void ValidatePathSubstitutions(ServerConfiguration newConfig)
+ {
+ foreach (var map in newConfig.PathSubstitutions)
+ {
+ if (string.IsNullOrWhiteSpace(map.From) || string.IsNullOrWhiteSpace(map.To))
+ {
+ throw new ArgumentException("Invalid path substitution");
+ }
+
+ if (!map.From.EndsWith(":\\") && !map.From.EndsWith(":/"))
+ {
+ map.From = map.From.TrimEnd('/').TrimEnd('\\');
+ }
+ if (!map.To.EndsWith(":\\") && !map.To.EndsWith(":/"))
+ {
+ map.To = map.To.TrimEnd('/').TrimEnd('\\');
+ }
+
+ if (string.IsNullOrWhiteSpace(map.From) || string.IsNullOrWhiteSpace(map.To))
+ {
+ throw new ArgumentException("Invalid path substitution");
+ }
+ }
+ }
+
/// <summary>
/// Replaces the item by name path.
/// </summary>