Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-18040

REST API escaping apostrophes wrong in WP

    Details

    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      The REST API inserts apostrophes in places.

      If I run this script:

      
      $options = array('query' => array(
          'key'=> API_SITE_KEY,
          'api_key'=>API_USER_KEY,
          'json' => 2,
          'entity'=>'contact',
          'action'=>'create',
          'email'=>'TEST1@EXAMPLE.org',
          'first_name'=>'Test',
          'last_name'=>'O\'Neil',
          'contact_type'=>'Individual',
      ));
      
      $res = $client->post(API_URL, $options);
      
      

      That's PHP Guzzle lib V5.3 BTW.

      I get: Test O\'Neil

      If I edit /wp-content/plugins/civicrm/civicrm/extern/rest.php and add at the top:

      <?php
      var_dump($_POST);
      var_dump($_GET);
      die();
      

      I see:

        ["first_name"]=>
        string(4) "Test"
        ["last_name"]=>
        string(6) "O'Neil"

      So it's not Guzzle adding the slash, it's CiviCRM or WordPress.

      On Wordpress 4.4.2, seen on Debian Stable server.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ShelterJames James
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: