-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Desktop: Rich Text Editor: Disallow inline event handlers #12106
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
base: dev
Are you sure you want to change the base?
Desktop: Rich Text Editor: Disallow inline event handlers #12106
Conversation
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx
Outdated
Show resolved
Hide resolved
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.
Note: Plugin asset files were regenerated due to changes to mermaid_render.js
.
// Clicking on export button manually triggers a right click context menu event | ||
const onClickHandler = ` |
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.
This onClick
handler was converted from an inline event handler to an event handler added by a script.
const allRules = { ...rules, ...this.extraRendererRules_ }; | ||
for (const key in allRules) { |
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.
This change (along with a few other modifications) add support for loading plugin-specified assets in the Rich Text Editor. This allows migrating inline event handlers to JavaScript files that aren't blocked by the content security policy. Plugin-specified assets were previously only supported in the Markdown viewer.
and media-src separately [This paper](https://dl.acm.org/doi/pdf/10.1145/2976749.2978363) suggests setting object-src to 'none'.
|
||
// Disallow certain unused features | ||
'child-src \'none\'', // Should not contain sub-frames | ||
'object-src \'none\'', // Objects can be used for script injection |
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.
Based on suggestions in https://dl.acm.org/doi/pdf/10.1145/2976749.2978363
Summary
This pull request enables the TinyMCE content_security_policy option, selecting a policy that:
onclick="..."
,onmouseenter="..."
).Goal: Make the Rich Text Editor more secure.
Important
This pull request may break certain plugins in the Rich Text Editor. For example, versions of the Freehand Drawing plugin before v3.0.0 don't support the Rich Text Editor with this change.
To allow plugins to continue to run scripts in the Rich Text Editor, this pull request also adds support for loading plugin assets registered by Joplin plugins in the Rich Text Editor (similar to the existing logic for the Markdown viewer). Previously, assets (e.g. CSS) specified by plugins were not loaded in the Rich Text Editor.
What does this break?
Certain plugins rely on inline event handlers in the Rich Text Editor. These include
Testing
I have verified that: