gocodebox / lifterlms

LifterLMS, a WordPress LMS Solution: Easily create, sell, and protect engaging online courses.
https://lifterlms.com
GNU General Public License v3.0
174 stars 134 forks source link

Backslashes are removed from result clarification content #2675

Open brianhogg opened 3 weeks ago

brianhogg commented 3 weeks ago

Reproduction Steps

  1. For a quiz question, add in content for the Result Clarification which includes a backslash
  2. Save Changes
  3. Refresh the page

Expected Behavior

The backslash characters are preserved.

Actual Behavior

The backslash characters are removed.

Tech Notes

From investigation, the slashes are present right up until the call to update_post_meta in abstract.llms.post.model.php::update_meta_properties. The documentation states that there is a call to stripslashes() so to compensate, we need to call wp_slash() beforehand:

https://developer.wordpress.org/reference/functions/update_post_meta/#more-information

However we're also stripping the slashes within LLMS_Admin_Builder::handle_ajax()

    $request['llms_builder'] = stripslashes( $request['llms_builder'] );

We may want to avoid doing this?

This issue has be recreated: