-
-
Notifications
You must be signed in to change notification settings - Fork 816
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
Fix slash in taxonomies #5675
Fix slash in taxonomies #5675
Conversation
} | ||
} | ||
} | ||
} |
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.
PSR-2 on the variable name case.
Also the nesting is a tad aggressive… Does this read better to you on review?
public function checkTaxonomy()
{
foreach ($this->data['taxonomy'] as $key => $taxonomy) {
if (empty($taxonomy['options']) || !is_array($taxonomy['options'])) {
continue;
}
foreach ($taxonomy['options'] as $optionKey => $optionValue) {
if (strpos($optionKey, '/') === false) {
continue;
}
$error = Trans::__(
'general.phrase.invalid-taxonomy-slug',
['%taxonomy%' => $key, '%option%' => $optionValue]
);
$this->app['logger.flash']->error($error);
}
}
}
@@ -71,6 +71,7 @@ public function before(Request $request, Application $app, $roleRoute = null) | |||
// Sanity checks for doubles in in contenttypes. This has to be done | |||
// here, because the 'translator' classes need to be initialised. | |||
$app['config']->checkConfig(); | |||
$app['config']->checkTaxonomy(); |
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.
Just flagging for the a.m.
This is not the place to be doing/firing this …
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.
Well, where is the right place? I didn't really know where to put it, so I followed the checkConfig way of doing things, and assumed that following established code was the way to go until we actually get to the config refactor. That way it's more predictable, no?
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.
Not sure yet, was mid-wife-night and just noticed this walking past my screen … let me look post- ☕
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.
OK … so after looking at it, and thinking about it … probably best for now to put that at the end of checkConfig()
as that is one of the things on my 🔥 list for the 3.2 exception/request work.
Short version is that we're checking on every request the configuration of the configuration … ConfigCeption … that is already cached … if it is cached, then we know it's already passed checks.
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.
Also moving the call means we can make that function private
and not expose another API
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.
c.f. master...GawainLynch:hotfix/config-check-request
Note that branch is for master
(3.2), but you should get the idea on direction.
Green it is going, it is … |
Fixes #5673
In taxonomy slugs we basically allow any character (since we do not slugify them). One way to test this is to add a tag with a bunch of special chars or with a taxonomy like this:
The only character that we cannot use or have is a slash since that denotes a separation of url portions.
This PR removes any slash found in a taxonomy slug (since that's how we do it in record slugs) and shows a warning flash message if a slash is put in a slug in taxonomy.yml.
PRing into 3.0 since this is a bug fix, let me know if I should retarget to 3.1.