-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Prevent using document.domain
by Firefox in the preview
plugin
#5439
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.
The changes seem to work properly, there are some more opportunities to simplify the code and we should probably update our tests a bit. Please, see my inline comments for more info.
plugins/preview/plugin.js
Outdated
nativePreviewWindow, | ||
previewUrl = '', |
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.
Do we need this variable at all? We could skip it altogether and just inline an empty string in the window.open()
call.
plugins/preview/plugin.js
Outdated
function generateBaseTag() { | ||
var template = '<base href="{HREF}">', | ||
origin = location.origin, | ||
pathname = location.pathname; | ||
|
||
if ( !config.baseHref && !CKEDITOR.env.gecko ) { | ||
return ''; | ||
} | ||
var template = '<base href="{HREF}">'; | ||
|
||
if ( config.baseHref ) { | ||
return template.replace( '{HREF}', config.baseHref ); | ||
} | ||
|
||
// As we use HTML file in Gecko, we must fix the incorrect base for | ||
// relative paths. | ||
pathname = pathname.split( '/' ); | ||
pathname.pop(); | ||
pathname = pathname.join( '/' ); | ||
|
||
return template.replace( '{HREF}', origin + pathname + '/' ); | ||
return ''; | ||
} |
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'm wondering if we can't simplify it even further, e.g. do we need the template at all?
function generateBaseTag() { | |
var template = '<base href="{HREF}">', | |
origin = location.origin, | |
pathname = location.pathname; | |
if ( !config.baseHref && !CKEDITOR.env.gecko ) { | |
return ''; | |
} | |
var template = '<base href="{HREF}">'; | |
if ( config.baseHref ) { | |
return template.replace( '{HREF}', config.baseHref ); | |
} | |
// As we use HTML file in Gecko, we must fix the incorrect base for | |
// relative paths. | |
pathname = pathname.split( '/' ); | |
pathname.pop(); | |
pathname = pathname.join( '/' ); | |
return template.replace( '{HREF}', origin + pathname + '/' ); | |
return ''; | |
} | |
function generateBaseTag() { | |
if ( !config.baseHref ) { | |
return ''; | |
} | |
return '<base href="' + config.baseHref + '">'; | |
} |
} | ||
|
||
// With Firefox only, we need to open a special preview page, so | ||
// anchors will work properly on it (https://dev.ckeditor.com/ticket/9047). |
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.
Could you add a manual test that will allow verifying if this issue is really not-reproducible anymore?
@@ -212,8 +200,7 @@ | |||
} | |||
|
|||
function getPreviewLocation() { | |||
// #(4444) |
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, it would be good to update manual tests for #444 to test if it still works (simply by adding the new version and issue tags).
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 assume you were referring to #4444?
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.
Yes 🙈
Thanks, @Comandeer for your input. I've applied changes mentioned in your comments and PR is ready for another review. |
It's been a while since we last heard from you. We are marking this pull request as stale due to inactivity. Please provide the requested feedback or the pull request will be closed after next 7 days. |
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.
LGTM!
What is the purpose of this pull request?
Task
Does your PR contain necessary tests?
All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
Did you follow the CKEditor 4 code style guide?
Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.
What is the proposed changelog entry for this pull request?
What changes did you make?
In the previous PR with fixing print on Firefox, we allowed using document.domain to properly open the preview before print while using the editor from CDN. Looks like FF fixed this and we can remove it.
Additionally, we could simplify the code more by removing fix for creating links to anchor.
Which issues does your PR resolve?
Closes #5412.