Title: Restoring a commit does not work properly.
Last modified: August 21, 2016

---

# Restoring a commit does not work properly.

 *  [invot](https://wordpress.org/support/users/invot/)
 * (@invot)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/)
 * When I commit a version of a file and then try to return it, my file is filled
   with an ‘n’ where my line breaks should be.
 * [http://wordpress.org/plugins/advanced-code-editor/](http://wordpress.org/plugins/advanced-code-editor/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [adriangreen](https://wordpress.org/support/users/adriangreen/)
 * (@adriangreen)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/#post-4053433)
 * I can confirm this in version 2.2.5.
    Clearly an escaping issue…
 * `<?phpn/**n *` …
 * The malformed html is present in the database table `filemeta` so it’s getting
   mangled on “commit”.
 *  [adriangreen](https://wordpress.org/support/users/adriangreen/)
 * (@adriangreen)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/#post-4053434)
 * Problem isolated:
    the problem is that on commit the code calls func `add_file_meta`
   which then calls built-in func `add_metadata` – this function uses func `wp_unslash`
   on the passed in value.
 * `wp_unslash` removes escape slashes like in
    `O\'Brian` >> `O'Brian`
 * So our poor newlines are being converted to “n”
 * `2 newlines next \n\nNewline here` >> `newline next nnNewline here`
 *  [adriangreen](https://wordpress.org/support/users/adriangreen/)
 * (@adriangreen)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/#post-4053435)
 * …aaaanyway
 * the simple fix for this is to not use `esc_sql` in function `ajax_commit_file`
   as subsequent call to `add_metadata` sanitizes input anyhow, it’s a bit redundant:
 * `$file_content = /**esc_sql**/($_POST['file_content']);`
 *  [widecast](https://wordpress.org/support/users/widecast/)
 * (@widecast)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/#post-4053498)
 * Adrian, thanks for the fix. I would have never figured that out myself. Working
   properly now!
 *  [widecast](https://wordpress.org/support/users/widecast/)
 * (@widecast)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/#post-4053503)
 * [@adrian](https://wordpress.org/support/users/adrian/), I just restored a theme
   file that had strings with escaped characters. Upon restoration, the file was
   messed up due to my escaped characters getting unescaped… I know you mentioned“
   wp_unslash” earlier which must be the culprit.
 * In your opinion, is this normal behavior? How can this be avoided?
 *  [adriangreen](https://wordpress.org/support/users/adriangreen/)
 * (@adriangreen)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/#post-4053504)
 * It can easily be avoided, but I don’t think the [author](http://profiles.wordpress.org/bainternet/)
   cares. The plugin is clearly incomplete in it’s realization. I stopped using 
   it. Idea: The data could be stored using base64_encode/decode to avoid all these
   issues.
    You’re best going to the author for a proper fix…

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Restoring a commit does not work properly.’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/advanced-code-editor_f4f3f4.svg)
 * [Advanced Code Editor](https://wordpress.org/plugins/advanced-code-editor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-code-editor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-code-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-code-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-code-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-code-editor/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [adriangreen](https://wordpress.org/support/users/adriangreen/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/restoring-a-commit-does-not-work-properly/#post-4053504)
 * Status: not resolved