-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fix toolbar load when GET params are present in "_wdt" route #32437
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
When using a custom router that inject GET parameters, eg: ``` # services.yaml parameters: # Replace default url generator service router.options.generator_base_class: Combodo\iTop\Portal\Routing\UrlGenerator ``` The path generated by the toolbar JS is HTML entity encoded which breaks the JS call (`&` becomes `&`).
Can you provide a minimal application that reproduces the problem? |
@Molkobain Can you tell us more about this issue? |
Hello guys, What do you means by a minimal app? About the issue, we extended the base UrlGenerator to propagate some parameters to all generated URLs as you will see on the code snippet below. It works fine in the application, URLs are generated as expected. <?php
namespace Combodo\iTop\Portal\Routing;
use utils;
use Symfony\Component\Routing\Generator\UrlGenerator as BaseUrlGenerator;
class UrlGenerator extends BaseUrlGenerator
{
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
{
$parameters = $this->getExtraParams($parameters);
return parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
}
private function getExtraParams($aParameters)
{
$sExecModule = utils::ReadParam('exec_module', '', false, 'string');
$sExecPage = utils::ReadParam('exec_page', '', false, 'string');
if ($sExecModule !== '' && $sExecPage !== '')
{
$aParameters['exec_module'] = $sExecModule;
$aParameters['exec_page'] = $sExecPage;
}
// Optional parameters
$sPortalId = utils::ReadParam('portal_id', '', false, 'string');
if ($sPortalId !== '')
{
$aParameters['portal_id'] = $sPortalId;
}
$sEnvSwitch = utils::ReadParam('env_switch', '', false, 'string');
if ($sEnvSwitch !== '')
{
$aParameters['env_switch'] = $sEnvSwitch;
}
$sDebug = utils::ReadParam('debug', '', false, 'string');
if ($sDebug !== '')
{
$aParameters['debug'] = $sDebug;
}
return $aParameters;
}
} The problem comes with the webprofiler in the webpage, when it tries to connect with the backend through XHR, the URL it calls is HTML entity encoded (check the "&"):
The backend then cannot decode the parameters and returns an error. Edit: Pressed Alt+Enter by mistake. I'm completing the comment and poking you when its complete. Sorry |
Thank you @Molkobain. |
…te (Molkobain) This PR was merged into the 3.4 branch. Discussion ---------- Fix toolbar load when GET params are present in "_wdt" route When using a custom router that inject GET parameters, eg: ``` # services.yaml parameters: # Replace default url generator service router.options.generator_base_class: Combodo\iTop\Portal\Routing\UrlGenerator ``` The path generated by the toolbar JS is HTML entity encoded which breaks the JS call (`&` becomes `&`). | Q | A | ------------- | --- | Branch? | 4.4 for features / 3.4, 4.2 or 4.3 for bug fixes <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> Commits ------- 5309e64 Fix toolbar load when GET params are present in "_wdt" route
When using a custom router that inject GET parameters, eg:
The path generated by the toolbar JS is HTML entity encoded which breaks the JS call (
&
becomes&
).