-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Inline oc.js when possible! #1917
Conversation
@rullzer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @LukasReschke, @DeepDiver1975 and @icewind1991 to be potential reviewers. |
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.
Awesome! Some nitpicks are still existent though ;)
/** @var JSConfigHelper */ | ||
private $helper; | ||
|
||
public function __construct($appName, |
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.
A kingdom for PHPDocs 🚀
@@ -18,6 +18,11 @@ | |||
<?php foreach($_['printcssfiles'] as $cssfile): ?> | |||
<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> | |||
<?php endforeach; ?> | |||
<?php if (isset($_['inline_ocjs'])): ?> | |||
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> | |||
<?php echo($_['inline_ocjs']); ?> |
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.
print_unescaped
? :)
@@ -19,6 +19,11 @@ | |||
<?php foreach($_['printcssfiles'] as $cssfile): ?> | |||
<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> | |||
<?php endforeach; ?> | |||
<?php if (isset($_['inline_ocjs'])): ?> | |||
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> | |||
<?php echo($_['inline_ocjs']); ?> |
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.
print_unescaped
? :)
@@ -26,6 +26,11 @@ | |||
<?php foreach($_['printcssfiles'] as $cssfile): ?> | |||
<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print"> | |||
<?php endforeach; ?> | |||
<?php if (isset($_['inline_ocjs'])): ?> | |||
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" type="text/javascript"> | |||
<?php echo($_['inline_ocjs']); ?> |
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.
print_unescaped
? :)
@@ -102,7 +105,8 @@ public function __construct(IRequest $request, | |||
$isLoggedIn, | |||
$isAdminUser, | |||
ContentSecurityPolicyManager $contentSecurityPolicyManager, | |||
CsrfTokenManager $csrfTokenManager) { | |||
CsrfTokenManager $csrfTokenManager, | |||
ContentSecurityPolicyNonceManager $cspNonceManager) { |
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.
Update PHPDoc? ;)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@LukasReschke fixed |
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Good stuff! 👍 |
Current coverage is 57.34% (diff: 3.01%)@@ master #1917 diff @@
==========================================
Files 1076 1078 +2
Lines 61310 61498 +188
Methods 6871 6875 +4
Messages 0 0
Branches 0 0
==========================================
- Hits 35266 35265 -1
- Misses 26044 26233 +189
Partials 0 0
|
Code looks good and I tested this in Firefox, Safari, Chrome, IE and Edge. 👍 |
Small addition: #1920 :) |
Please also delete the old file, just cost björn and me some minutes to figure out, why the break point didn't stop... |
With #1871 in we can now do fancy pancy stuff. Like inline javascript safely.
This PR bring you the inlining of oc.js. This file was loaded on each pageload separatly and was a blocking call! Now if your browser support CSPv3 it will inline the file saving you a blocking (non cacheable request!).
@LukasReschke as discussed!
CC: @MorrisJobke @nickvergessen @icewind1991