Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Custom JS is being Escaped #1046

Open
SolidX opened this issue Mar 21, 2016 · 9 comments
Open

Custom JS is being Escaped #1046

SolidX opened this issue Mar 21, 2016 · 9 comments

Comments

@SolidX
Copy link

SolidX commented Mar 21, 2016

Summary

When including custom Javascript in a post, it displays properly on the post edit page but renders with escaped characters when viewing a post. This causes scripts to break.

Reproduction Steps

  1. Create a post.
  2. Add custom JS via drag and drop
  3. Save post.
  4. View Post

Expected Behaviour

Should render unescaped javascript when viewing post. ex. var x = 9001 > 42;

Actual Behaviour

Actually renders escaped javascript. ex. var x = 9001 > 42;

Context details (if applicable)

@protomorph
Copy link

@SolidX in anchor/functions/article.php replace return Registry::prop('article', 'js'); with return htmlspecialchars_decode(Registry::prop('article', 'js'), ENT_QUOTES); and see if that works.

@SolidX
Copy link
Author

SolidX commented Mar 21, 2016

@protomorph That solves it! Thanks!

@protomorph
Copy link

@SolidX No problem.

@TheBrenny
Copy link
Member

@protomorph, reckon you can drop this in a PR? :D

@protomorph
Copy link

@TheBrenny I'll get one done in the next few hours.

@frozenpandaman
Copy link

@protomorph After making this change, article text is being displayed as-is (e.g. no markdown or HTML rendering) on the main page of my site. Must we change a article_markdown() call to article_html() somewhere?

@protomorph
Copy link

@frozenpandaman Making this change doesn't effect anything else, you must of changed somthing to stop markdown from rendering

@frozenpandaman
Copy link

@protomorph I don't think so. I changed the line back to how it was originally and blog posts started displaying correctly again… I'll look more into it tonight, though.

@Gerrit0
Copy link
Contributor

Gerrit0 commented Jun 3, 2016

Well, here's where the problem was introduced: bc202b5

All input is escaped when first fetched using Input::get, so it needs to be decoded again. I can't say I agree that encoding everything in this function is a good idea... I'll hopefully make PR resolving this (and escaping input where the default escaping was relied on) soon.

CraigChilds94 added a commit that referenced this issue Feb 19, 2017
Fix for #1046 (Custom JS is being escaped)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants