-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Change default for queryStringDelete #21586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Not sure why the tests are failing here, the test in question is not related to my changes. I am not able to build the aspnet core project, it complains about needing a new version of MSBuild but I have the latest version of VS2019 installed. |
The VerifyTrackAllCaptures and VerifyTrackAllCapturesRuleAndConditionCapture tests don't expect a query string but now there is one. The asserts need updating.
|
halter73
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this a little more, I now see that queryStringAppend defaults to true.
The rule in VerifyTrackAllCaptures is one that is pulling data out of the query string and putting it into the path. Appending the query string in this case would be unexpected and breaking. I don't think we can actually
| pattern, | ||
| queryStringAppend, | ||
| queryStringDelete: true, | ||
| queryStringDelete: !queryStringAppend, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this a little more, I now see that UrlRewriteFileParser creates RedirectActions with queryStringAppend defaulted to true.
The rule in VerifyTrackAllCaptures is one that is pulling data out of the query string and putting it into the path. Appending the query string in this case would be unexpected and breaking.
We have to decide how the UrlRewriteFileParser should behave when appendQueryString is unspecified. Right now, it looks like it appends the request query string if there's a querystring in the pattern, and does not append the request querystring if there's no querystring in the pattern. I doubt this is how IIS behaves. @jkotalik Do you know what the behavior is supposed to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with IIS, it appends the query string every time unless appendQueryString="false"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we go ahead and remove this constructor and fix the call site in UrlRewriteFileParser to pass in queryStringDelete as !queryStringAppend.
I realize a lot of this confusion is coming from the fact that this class is shared between UrlRewrite and Apache ModRewrite.
|
Thanks @halter73 - I am up and running now, thought I had all the pre-requisites installed. Tests updated. |
|
FWIW - not sure this needs QueryStringDelete, is there a case where append and delete would both be false or true? Line 85 - Could be just Seems to have been added to keep the same parameters as RewriteAction, it's usage there seems to really mean remove it before continuing. Again it might be that line 131 - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with IIS, it appends the query string every time unless appendQueryString="false"
Seems good to me then. @jkotalik Do you think this warrants a breaking change announcement?
|
Hm, on the fence whether we should have a breaking change announcement for this. It's a bug fix that does generally seem like bad behavior, but at the same time we may want to still announce it. I'm not sure what our policy is on breaking changes now; should we announce any breaking change at all? @pranavkm thoughts? |
I haven't looked at IIS's behavior, so I could be wrong here. But it seems to me by looking at the existing buggy code that QueryStringAppend was meant apply to the pattern and QueryStringDelete was meant to apply to the request query string.
That said. If you wanted to strip the query string from the pattern, you could just not include a query string in the pattern. It would be a lot simpler if QueryStringAppend controlled whether or not to keep the request query string and have the pattern query string always appended if present. I'm not sure if this is compatible with IIS's behavior though. |
You can test IIS's behavior by installing the rewrite module and then it has a UI for testing different rules. |
|
I'm going to take a look at how IIS rules play into this here to verify the behavior here. It seems clear we aren't 100% certain on what the behavior should be here. |
|
Looked at the code and seems good now. IIS only has an option for appendQueryString, so the fix makes sense as appendQueryString being true implies queryStringDelete is false. I'll make a breaking change announcement and add something to our 5.0 migration guide after this PR is merged. |
|
@jkotalik Ping |
src/Middleware/Rewrite/src/IISUrlRewrite/UrlRewriteFileParser.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Brennan <[email protected]>
|
@pranavkm where is there a migration guide? |
Summary of the changes (Less than 80 chars)
Change the default value to be opposite of queryStringAppend
Addresses #21464