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 html export with ep_headings2 #33

Merged
merged 1 commit into from
Dec 18, 2020
Merged

Fix html export with ep_headings2 #33

merged 1 commit into from
Dec 18, 2020

Conversation

ilmartyrk
Copy link
Contributor

When using together with ep_headings2 the ep_headings currently replace existing text formatting, but this fix together with ep_headings2 fix will allow headings to be aligned with valid HTML.

@JohnMcLear
Copy link
Member

JohnMcLear commented Dec 17, 2020

eslint fixes please :)

@ilmartyrk
Copy link
Contributor Author

@JohnMcLear sorry about that, fixed now, also went over tests again, there was some kind of a syntax diff between my local tests and here, anyway this pull will work together with this ether/ep_headings2#38

if (heading.indexOf('style=') === -1) {
context.lineContent = context.lineContent.replace('>', ` style='text-align:${align}'>`);
} else {
context.lineContent = context.lineContent.replace('style=', `style='text-align:${align} `);
Copy link
Member

Choose a reason for hiding this comment

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

The content isn't being escape here any more dude??? Isn't that a problem? 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you check ep_headings2 plugin it isn't escaped there too as it will remove any html added by other plugins. Probably one way to fix would be to check line with indexOf('script') > -1' and if does then use Security.escapeHTML. Would that be acceptable?

Copy link
Member

Choose a reason for hiding this comment

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

hrm, I'm sure at some point we addressed this.. script wouldn't suffice, too easy to manipulate...

Copy link
Contributor Author

@ilmartyrk ilmartyrk Dec 17, 2020

Choose a reason for hiding this comment

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

I don't see other plugins using Security.escapeHTML in getLineHTMLForExport:
https://github.com/ether/ep_font_color/blob/a3760585b9970df4d8562e8df1aea6fe3587ed91/exportHTML.js#L21
https://github.com/ether/ep_font_size/blob/e5318a81dd8b035e1cc1aa1fe5c905156fc65e2d/exportHTML.js#L18
I am not saying it shouldn't but just looks weird if one plugin does and others don't. Maybe it would be better to find some solution after hook call in main project.

@JohnMcLear
Copy link
Member

FWIW this plugin used to do it: https://github.com/ether/ep_align/pull/33/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346L38

There will be a reason I did that 👍

Can't you escape plugins such as font family/size/align content and not escape in ep_headings or??

I guess the issue is if you have a color wthin an alignment? Tricky one ;(

Does the alert example actually work? I'm only assuming it's a security issue, there might be something fancy going on that stops it being an issue....??

@ilmartyrk
Copy link
Contributor Author

ilmartyrk commented Dec 18, 2020

@JohnMcLear I played around with it and only way I could insert any script was through using getLineHTMLForExport so basically only way of injection happening is through a malicious plugin. Maybe I am missing something. Ways I tested were:

  1. Altered test to add script tags or onclick attributes
  2. Tried adding script from UI
    Seems that script was escaped in some other place and final result didn't have any script tags unless I added it through plugins hook.

@JohnMcLear JohnMcLear merged commit 88886e4 into master Dec 18, 2020
@JohnMcLear
Copy link
Member

Perfect, let's go!

@rhansen rhansen deleted the html_export_fix branch January 9, 2021 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants