Skip to content
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 JS bundle URL escape #1465

Merged
merged 5 commits into from
Oct 1, 2020
Merged

Fix JS bundle URL escape #1465

merged 5 commits into from
Oct 1, 2020

Conversation

mvorisek
Copy link
Member

@mvorisek mvorisek commented Oct 1, 2020

we must escape for JS/JSON, not using HTML

@@ -61,7 +61,7 @@
// ****** CREATING CUSTOM VUE USING EXTERNAL COMPONENT *****************************
\atk4\ui\Header::addTo($app, ['External Component', 'subHeader' => 'Creating component using an external component definition.']);

$app->requireJs('https://unpkg.com/vue-clock2@1.1.5/dist/vue-clock.min');
$app->requireJs('https://unpkg.com/vue-clock2@1.1.5/dist/vue-clock.min.js');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just prevent unneeded redirect...

src/App.php Outdated
@@ -465,7 +465,7 @@ public function initIncludes()
$this->requireCss($this->cdn['atk'] . '/agileui.css');

// Set js bundle dynamic loading path.
$this->html->template->trySet('PublicPath', $this->cdn['atk']);
$this->html->template->trySet('InitJsBundle', (new JsExpression('window.__atkBundlePublicPath=[]', [$this->cdn['atk']]))->jsRender(), false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsRender can not close script tag, thus 100% safe to not escape by definition

* @param array $args
*/
public function __construct($template = '', $args = [])
public function __construct(string $template = '', array $args = [])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array tag type is super important - otherwise string can be passed without any warning!

Copy link
Contributor

@ibelar ibelar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ibelar ibelar merged commit 2c822b8 into develop Oct 1, 2020
@ibelar ibelar deleted the fix_bundle_url_escape branch October 1, 2020 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants