Browse Source

Better parsing syntax

Former-commit-id: 63a8af4cd3f098e2aac86af2f80cc4458ea28a84
Former-commit-id: e92a9428b879dd6ec25cc464dfcc2870bf7467fe
pull/17/head
James South 11 years ago
parent
commit
e8978fd69e
  1. 2
      src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs
  2. 4
      src/ImageProcessor.Web/Processors/Hue.cs
  3. 4
      src/ImageProcessor.Web/Processors/ReplaceColor.cs
  4. 2
      src/ImageProcessor.Web/Processors/Rotate.cs

2
src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs

@ -39,7 +39,7 @@ namespace ImageProcessor.Web.Helpers
/// <summary>
/// The regular expression to search strings for angles.
/// </summary>
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);
/// <summary>
/// The regular expression to search strings for values between 1 and 100.

4
src/ImageProcessor.Web/Processors/Hue.cs

@ -25,7 +25,7 @@ namespace ImageProcessor.Web.Processors
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"(hue=|rotatehue=)[^&]+", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"(hue=|hue.\w+=)[^&]+", RegexOptions.Compiled);
/// <summary>
/// The hue regex.
@ -35,7 +35,7 @@ namespace ImageProcessor.Web.Processors
/// <summary>
/// The rotate regex.
/// </summary>
private static readonly Regex RotateRegex = new Regex(@"rotatehue=true", RegexOptions.Compiled);
private static readonly Regex RotateRegex = new Regex(@"hue.rotate=true", RegexOptions.Compiled);
/// <summary>
/// Initializes a new instance of the <see cref="Hue"/> class.

4
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();

2
src/ImageProcessor.Web/Processors/Rotate.cs

@ -22,7 +22,7 @@ namespace ImageProcessor.Web.Processors
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"(rotate|angle)(=|-)[^&|,]+", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"([^.](&,=)?rotate|angle)(=|-)[^&|,]+", RegexOptions.Compiled);
/// <summary>
/// Initializes a new instance of the <see cref="Rotate"/> class.

Loading…
Cancel
Save