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

Encode field values sent in autocompleter requests #380

Merged
merged 1 commit into from Apr 10, 2024

Conversation

alex-ball
Copy link
Contributor

@alex-ball alex-ball commented Apr 9, 2024

When autocompleting a compound field, the parameters sent include the value of the active field and the values of all the component fields. Currently, the value of the active field is URI-encoded but the other values are not. Let's say the creators field has an affiliation subfield:

q=Example%20College%3B%20University
&name_family=Smith
&name_given=Sam
&affiliation=Example College; University

This is normally harmless since few characters cause issues in this context and unescaping occurs before the values reach the processing script. However, in CGI.pm v2.64+, the semicolon is treated as an alias for ampersand and therefore terminates the value. This means when using $session->param we get

q => 'Example%20College%3B%20University',
affiliation => 'Example College'

This PR applies URI encoding to the field values added by the ep_autocompleter callback so they are handled equivalently to the q parameter.

When autocompleting a compound field, the parameters sent include the
value of the active field and the values of all the component fields.
Currently, the value of the active field is URI-encoded but the other
values are not. Let's say the creators field has as affiliation
subfield:

```
q=Example%20College%3B%20University
&name_family=Smith
&name_given=Sam
&affiliation=Example College; University
```

This is normally harmless since few characters cause issues in this
context and unescaping occurs before the values reach the processing
script. However, in CGI.pm v2.64+, the semicolon is treated as an
alias for ampersand and therefore terminates the value. This means when
using `$session->param` we get

```
q => 'Example%20College%3B%20University',
affiliation => 'Example College'
```

This PR adds URI encoding to the field values added by the
`ep_autocompleter` callback so they are handled equivalently to the `q`
parameter.
Copy link
Contributor

@drn05r drn05r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested this on my own development problem and I can see the same issue. This change appears to fix the issue.

@drn05r drn05r merged commit 5660967 into eprints:master Apr 10, 2024
@alex-ball alex-ball deleted the patch-1 branch April 24, 2024 12:36
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

Successfully merging this pull request may close these issues.

None yet

2 participants