From e8978fd69eced1aaf1ad5db79f4f55ee2e27fff7 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 11 Nov 2014 00:36:56 +0000 Subject: [PATCH] Better parsing syntax Former-commit-id: 63a8af4cd3f098e2aac86af2f80cc4458ea28a84 Former-commit-id: e92a9428b879dd6ec25cc464dfcc2870bf7467fe --- .../Helpers/CommonParameterParserUtility.cs | 2 +- src/ImageProcessor.Web/Processors/Hue.cs | 4 ++-- src/ImageProcessor.Web/Processors/ReplaceColor.cs | 4 ++-- src/ImageProcessor.Web/Processors/Rotate.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs index 17e931ec8..0f252a570 100644 --- a/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs +++ b/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs @@ -39,7 +39,7 @@ namespace ImageProcessor.Web.Helpers /// /// The regular expression to search strings for angles. /// - private static readonly Regex AngleRegex = new Regex(@"(rotate|angle)(=|-)(-)?\d+(.?\d+)?", RegexOptions.Compiled); + private static readonly Regex AngleRegex = new Regex(@"([^.](&,=)?rotate|angle)(=|-)(-)?\d+(.?\d+)?", RegexOptions.Compiled); /// /// The regular expression to search strings for values between 1 and 100. diff --git a/src/ImageProcessor.Web/Processors/Hue.cs b/src/ImageProcessor.Web/Processors/Hue.cs index 379ccffc9..a92f809f6 100644 --- a/src/ImageProcessor.Web/Processors/Hue.cs +++ b/src/ImageProcessor.Web/Processors/Hue.cs @@ -25,7 +25,7 @@ namespace ImageProcessor.Web.Processors /// /// The regular expression to search strings for. /// - private static readonly Regex QueryRegex = new Regex(@"(hue=|rotatehue=)[^&]+", RegexOptions.Compiled); + private static readonly Regex QueryRegex = new Regex(@"(hue=|hue.\w+=)[^&]+", RegexOptions.Compiled); /// /// The hue regex. @@ -35,7 +35,7 @@ namespace ImageProcessor.Web.Processors /// /// The rotate regex. /// - private static readonly Regex RotateRegex = new Regex(@"rotatehue=true", RegexOptions.Compiled); + private static readonly Regex RotateRegex = new Regex(@"hue.rotate=true", RegexOptions.Compiled); /// /// Initializes a new instance of the class. diff --git a/src/ImageProcessor.Web/Processors/ReplaceColor.cs b/src/ImageProcessor.Web/Processors/ReplaceColor.cs index 1e7592d0a..940a50ad3 100644 --- a/src/ImageProcessor.Web/Processors/ReplaceColor.cs +++ b/src/ImageProcessor.Web/Processors/ReplaceColor.cs @@ -130,8 +130,8 @@ namespace ImageProcessor.Web.Processors Match match = ReplaceRegex.Match(input); if (match.Success) { - string[] colorQuery = match.Value.Split('=')[1].Split('|'); - colors = colorQuery.Select(CommonParameterParserUtility.ParseColor); + string[] colorQuery = match.Value.Split('=')[1].Split(new[] { "],[" }, StringSplitOptions.None); + colors = colorQuery.Select(s => CommonParameterParserUtility.ParseColor(s.Replace("[", string.Empty).Replace("]", string.Empty))); } return colors.ToArray(); diff --git a/src/ImageProcessor.Web/Processors/Rotate.cs b/src/ImageProcessor.Web/Processors/Rotate.cs index 7ab41f7da..155b4a286 100644 --- a/src/ImageProcessor.Web/Processors/Rotate.cs +++ b/src/ImageProcessor.Web/Processors/Rotate.cs @@ -22,7 +22,7 @@ namespace ImageProcessor.Web.Processors /// /// The regular expression to search strings for. /// - private static readonly Regex QueryRegex = new Regex(@"(rotate|angle)(=|-)[^&|,]+", RegexOptions.Compiled); + private static readonly Regex QueryRegex = new Regex(@"([^.](&,=)?rotate|angle)(=|-)[^&|,]+", RegexOptions.Compiled); /// /// Initializes a new instance of the class.