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

sanitizing and encoding, fixes #431 (xss) #444

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
2 participants
@jnorell
Copy link
Contributor

commented Sep 28, 2018

No description provided.

@Reedyseth

This comment has been minimized.

Copy link
Member

commented Dec 13, 2018

Hello @jnorell ,
I am working to merge this code on the development version, but I will change some functions for WordPress function built in to sanitize information. For example wp_json_encode( $email ) is no sanitizing the information. You can review the function to get more details. I will accept you changes and the replace the functions.

Best regards and thank you for your contributions.

@Reedyseth

This comment has been minimized.

Copy link
Member

commented Dec 13, 2018

@jnorell Thank you for your contribution. I have added you code to the latest dev code 2f37d33. I am working this day to get the new version for the next week. You are happy to download the dev version and testing.

@Reedyseth Reedyseth closed this Dec 13, 2018

@jnorell

This comment has been minimized.

Copy link
Contributor Author

commented Dec 13, 2018

Thanks for picking this up, @Reedyseth!

Regarding that wp_json_encode( $email ), I believe it should not be a problem because all paths to set $email are safe, it either comes from the global $current_user object or from a cookie where it is run through sanitize_email(). I did attempt to trace all code paths to set the variables to ensure they were safe (though as always you can miss something, so I just double-checked and came to the same conclusion). So it appears $email is sanitized before handing to wp_json_encode(), which will then encode whatever value it is given (a sanitized email address or anything else) and encode it safely for javascript output.

I'll take a look at the latest code and get things updated - thanks again!

@Reedyseth

This comment has been minimized.

Copy link
Member

commented Dec 14, 2018

@jnorell The function wp_json_encode() does not convice me about sanitizing information. As you can see on the video I have debug the code and in no point the information is sanitize as in esc_attr()

...

Please share your comments. I just want to be clear about using the correct functions.

Update

In some parts of the web they recommend to use json_encode for this situation which is the same as using the wp_json_encode function. so I might change it to that. Let me know your thoughts.

Regards.!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.