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

find_by_email method does not follow osdi encapsulation rules exactly #24

Open
matthewbretherton opened this issue Jan 17, 2023 · 2 comments

Comments

@matthewbretherton
Copy link

A request for an email with an apostrophe (') in it returned an error from Action Network

A lucky guess found that a two apostrophes ('') (as per mysql encapsulation) worked

Further reading on osdi found documentation that a single apostrophe in a search query needs to be escaped with another single apostrophe

My monkey patch

module ActionNetworkRest
class People < Base
def find_by_email(email)
# This works for parsing exactly 1 person's info out of the response.
# The response we get from Action Network is expected to have
#
# "_embedded": {
# "osdi:people": [{
# "identifiers": [
# "action_network:c947bcd0-929e-11e3-a2e9-12313d316c29"
# ....
# ]
# }]
# }
#
osdi_encoded_string = email.gsub("'","''")
url_encoded_filter_string = url_escape("email_address eq '#{osdi_encoded_string}'")
response = client.get_request "#{base_path}?filter=#{url_encoded_filter_string}"
person_object = response.body[:_embedded][osdi_key].first
set_action_network_id_on_object(person_object) if person_object.present?
end
end
end

@lavaturtle
Copy link
Contributor

Wow, good catch! We'll see about fixing this. Thanks!

@matthewbretherton
Copy link
Author

matthewbretherton commented Jan 19, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants