Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Conversation

@ronaldbarendse
Copy link
Collaborator

@ronaldbarendse ronaldbarendse commented Apr 2, 2019

In addition to PR #728, this changes the Regex options to ignore casing within the query string, use culture invariant and explicit capture to improve performance and correctly escapes input used in the patterns.

Because processors are matched using a Regex expression, but (if matched) use the case insensitive query string (NameValueCollection), some weird behavior can be experienced:

  • image.jpg?width=300 - resizes to 300
  • image.jpg?Width=300 - returns original image, no processing is done!
  • image.jpg?width=300&height=200 - resizes to 300x200
  • image.jpg?Width=300&height=200 - resizes to 300x200, because height is matched in the Regex and the Resize processor then parses the query string in a case insensitive way and can successfully get both width and height!

ronaldbarendse pushed a commit to ronaldbarendse/ImageProcessor that referenced this pull request Apr 3, 2019
@ronaldbarendse
Copy link
Collaborator Author

I've updated the branch, so it's now based on the latest develop branch. This fixes the described problem with different query string casings, includes additional Regex escaping and improved performance (by moving to static readonly fields and adding CultureInvariant, ExplicitCapture and IgnoreCase options as per best practice)!

@JimBobSquarePants JimBobSquarePants merged commit 43cab79 into JimBobSquarePants:develop Jul 17, 2019
@ronaldbarendse ronaldbarendse deleted the fix-regexreplace branch February 13, 2020 21:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants