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

Encoding issue when POSTing to DataCite API #13

Closed
drn05r opened this issue Mar 27, 2017 · 3 comments
Closed

Encoding issue when POSTing to DataCite API #13

drn05r opened this issue Mar 27, 2017 · 3 comments
Milestone

Comments

@drn05r
Copy link

@drn05r drn05r commented Mar 27, 2017

If a title or other piece of metadata that needs to be included in the XML POSTed to the DataCite API contains non-standard characters it causes the event queue task to fail. This looks to be an encoding issue. This can seemingly be fixed by adding the following line to the datacite_request method of lib/plugins/EPrints/Plugin/Event/DataCiteEvent.pm before the HTTP::Request:

utf8::encode($content) if $content =~ /[^\x00-\xFF]/;

@photomedia
Copy link

@photomedia photomedia commented Jun 13, 2017

I encountered the same issue, the error message (in indexer.log) was:

Event::DataCiteEvent::datacite_doi: Error during execution: HTTP::Message content must be bytes at /opt/eprints3/lib/plugins/EPrints/Plugin/Event/DataCiteEvent.pm line 83

For me, line 83 is: my $req = HTTP::Request->new(

I added line suggested by drn05r, and it solved the problem.
I had to remember to restart the indexer before the change took effect.

To reproduce the issue, use this as the eprint title: "Émerger des décombres… Œuvres et poèmes retrouvés : créations d’art-thérapie"

@drn05r
Copy link
Author

@drn05r drn05r commented Oct 10, 2017

After further review, technically the fix should be:

utf8::encode($content) if $content =~ /[^\x00-\x7E]/;

That said there should not be any issue with making sure it is UTF-8 encoded come what may. So just use:

utf8::encode($content);

@goetzk goetzk added this to the v2.3 milestone Sep 18, 2018
@goetzk goetzk removed this from the v2.3 milestone Sep 18, 2018
@goetzk goetzk added this to the v2.2 milestone Sep 18, 2018
@goetzk
Copy link
Member

@goetzk goetzk commented Sep 20, 2018

Encoding of the content was added in ec11dca; the headers are hard coded in the calling function so are safe (for now).
Given that, I'm resolving this issue as complete.

@goetzk goetzk closed this Sep 20, 2018
@goetzk goetzk removed this from the v2.2 milestone Dec 14, 2018
@goetzk goetzk added this to the v2.1 milestone Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants