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

API Contact get fails when search string contains apostrophe

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.1
    • Fix Version/s: 4.3.1
    • Component/s: CiviCRM API
    • Labels:
      None

      Description

      The contact get API function fails to return any records when a search string contains an apostrophe, e.g. last_name => "O'Reilly".

      To reproduce this on the demo environment, go to the API Explorer ( http://drupal.demo.civicrm.org/civicrm/api/explorer ), select Contact, get, and and a parameter to the query string to search for an existing contact whose name contains an apostrophe, e.g. household_name=Sheila Smith's home. You will get no results. Now replace the apostrophe with a % and you will get the result you should have got before.

      From examining the MySQL log file it seems that each apostrophe is being prefixed by three backslashes, e.g. ' becomes \\\'. Each apostrophe should be prefixed by a single backslash, not three backslashes. It seems likely that the API is unnecessarily escaping the search string twice, so ' becomes \' becomes \\\'.

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              kirk Kirk Jackson
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: