-
Notifications
You must be signed in to change notification settings - Fork 379
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
[Templating] Handle uri query strings passed to templating extension and helper #933
Conversation
@@ -40,7 +43,13 @@ public function __construct(CacheManager $cacheManager) | |||
*/ | |||
public function filter($path, $filter, array $runtimeConfig = array()) | |||
{ | |||
return $this->cacheManager->getBrowserPath($path, $filter, $runtimeConfig); | |||
$pathParts = explode('?', $path, 2); |
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'd love to hear a better name than $pathParts
🙄
I tried list($path, $queryString)
, which looks a lot better, but doesn't work when the original path doesn't contain a question mark (undefined index 1)
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.
you can try this, to keep list function use.
list($path, $queryString) = array_pad(explode('?', $path, 2), 2, null);
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.
It works, but is quite hard to read IMO.
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 agree, $pathParts sounds betters.
Waiting this merge.
We've discussed this in the past and one other idea brought up was to expose a configuration option that would enable this behavior. Also, isn't it possible that such handling should exist outside the templating component as well? |
I consciously restricted the behaviour to the templating component because of the nature of templates, where it is easy to mix up paths and URLs. Other components should in my opinion only deal with paths and not concern themselves with query strings. In terms of hexagonal architecture I think of the templating component as an infrastructure thing where user input is received that might be messy, whereas after that we enter the application layer, where input should be normalised to adhere to the application spec. So that is why I've made the templating component forgiving of query strings and fix them when sending them to the application and adding them back to the application response, but the rest of the bundle is still blissfully unaware of query strings. |
+1 |
So, while I prefer this behavior over our current handling, I consider this a BC break. Many filesystems are happy to allow a filename such as "my-cool-image?with=an&odd=name.jpg" and this change would break such a usage. As such, we need to default to the old behavior and add the ability to enable this behavior via a configuration toggle for the I already have a commit that adds the configuration required to do this, and I'll push it to this PR shortly, as I'd like to include this in the next release. Just wanted to give everyone a heads up as to any progress. |
This PR has been open for a long time (since May of this year). |
@rpkamp you could as suggested by @robfrawley or simply change the base branch to 2.0 |
I've been thinking about this some more and have come to the conclusion that this PR solves the wrong problem. The problem is that the filter is applied to the output of As such, I'm closing this PR. |
Gracefully handle any query strings in paths passed to the templating filters.
See added tests for behaviour.