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

Code editor is bugged in a couple of ways #11

Open
SteidleSolutions opened this issue Sep 19, 2023 · 1 comment
Open

Code editor is bugged in a couple of ways #11

SteidleSolutions opened this issue Sep 19, 2023 · 1 comment

Comments

@SteidleSolutions
Copy link

SteidleSolutions commented Sep 19, 2023

The code editor module seems to be bugged in a few ways. The first is that you can't edit or type in it until you hit save changes and it refreshes the page. What you have typed in the editor also doesn't show until you click the box and when it shows the CSS is all messed up.

Initial load:
image

After clicking the editor (but can't type):
image

After clicking save changes and it reloads (now fully functional):
image

Then the next is that it doesn't seem to be saving some chracters correctly. Notably <> and ''.
For example, if I put in
<script>console.log('loaded in header');</script>
When I try and put that into the header it outputs as
<script>&lt;script&gt;console.log(&#039;loaded in header&#039;);&lt;/script&gt;</script>
image
No matter which way I try and echo or insert into the header it doesn't seem to ever want to show correctly.

This can also be observed if using the code editor to collect CSS. If you enter code such as

#test > .test {
color: red;
}

The > will be replaced with < and break the CSS.

I thought I could get around it by just using a textarea box but those sanatize the input and remove tons of characters.

@SteidleSolutions SteidleSolutions changed the title Code editor is bugged in a lot of ways Code editor is bugged in a couple of ways Sep 19, 2023
@leichim
Copy link
Member

leichim commented Oct 9, 2023

Thanks SteidleSolutions for the clear explanation.

Input from the code field is indeed sanitized, where slashes and html entities are converted to prevent authenticated XSS.

At the moment I am too occupied to fix this in a short term, but feel free to initiate a PR with the suggested improvements for the code.

In the meantime, you could use the ''wp_custom_fields_sanitized_value' filter to overwrite the default output for the code field (or any other type of field). (See src/Validate.php:453)

There are also two filters in the src/Frame.php class which you can use to overwrite behaviour for the Code field.
wp_custom_fields_field_class
wp_custom_fields_field_form

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

No branches or pull requests

2 participants