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

Email addresses with '+' tags #22

Closed
Don-L opened this issue Mar 5, 2018 · 4 comments
Closed

Email addresses with '+' tags #22

Don-L opened this issue Mar 5, 2018 · 4 comments
Labels

Comments

@Don-L
Copy link

Don-L commented Mar 5, 2018

Hello, loving the library - thanks very much for this!

I've come across a potential issue with the encoding of email addresses which contain a '+', e.g. email+alias@email.com. Submitting a query with such an address in the filter argument of retrieveMultiple for example doesn't return any matches for me, even where a matching entity is known to exist in my Dynamics instance.

Making a change to line 213 in convertRequest in utilities/RequestConverter seems to fix the issue:

if (result.query) {
result.url += "?" + encodeURI(result.query);
}

at line 213 to

if (result.query) {
result.url += "?" + encodeURI(result.query).replace(/+/g, "%2B");
}

Thanks again

Donald

@AleksandrRogov
Copy link
Owner

Hi @Don-L ,
I will take a look at it asap. Thank you for submitting this issue.

@CallumHogg
Copy link

Maybe we can use encoreURIComponent on each item in convertRequestOptions and then remove the overall encodeURI around the query in convertRequest?

The problem with using encodeURIComponent and then encodeURI is it will replace the escaped characters with more escaped characters e.g. test+email@example.com would get converted to test%2bemail@example.com which is right but then when encodeURI goes over it it would then become test%252bemail@example.com

@AleksandrRogov
Copy link
Owner

Hi @CallumHogg ,
If we are going to use encoreURIComponent then we will need to apply it to each query parameter, and not to a whole query string as we are doing now.

One way or another, I will need to test each request thoroughly, so I am 100% sure I am not breaking anything (I had issues with query encoding before, I do not clearly remember, but I think it was connected to RetrieveMultiple of the next page url query parameter, because encoding there is weird).

@AleksandrRogov
Copy link
Owner

Most probably, we need to encode all components separately using encodeURIComponent, because the characters that encodeURI does not encode could potentially be somewhere in the filter request, for example: to filter a text "How are you?" - which will result in an error.

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

No branches or pull requests

3 participants