Fix bad utf8 decoding, also fix cgi->header(-status) to redirect to one of the posible error pages in /cgi-bin/koha/errors/
Created attachment 44861 [details] [review] 15190 - Bad utf8 decode to unapi and fixing blank screen error status Fix bad utf8 decoding, also fix cgi->header(-status) to redirect to one of the posible error pages in /cgi-bin/koha/errors/ To test 1) Copy from LOC (Z39.50) ISBN 8467020113 2) Open URL cgi-bin/koha/unapi?id=koha:biblionumber:4&format=marcxml 3) (enter the new biblionumber for ISBN 8467020113) 4) A marcxml record will display, notice about the bad utf8 decoding characters 5) Search the record in opac and try to save in Zotero (see bad decoding) delete record from Zotero. 6) To reproduce blank screen (error status) play with: cgi-bin/koha/unapi?id=koha:biblionumber:4 cgi-bin/koha/unapi?id=koha:biblionumber:4&format= cgi-bin/koha/unapi?id=koha:biblionumber:4&format=none cgi-bin/koha/unapi?id=koha:biblionumber:&format=marcxml cgi-bin/koha/unapi?&format=oai_dc cgi-bin/koha/unapi? 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8 and redirection to one of the error pages in /cgi-bin/koha/errors/
Created attachment 44887 [details] [review] Bug 15190: Bad utf8 decode to unapi and fixing blank screen error status Fix bad utf8 decoding, also fix cgi->header(-status) to redirect to one of the posible error pages in /cgi-bin/koha/errors/ To test 1) Copy from LOC (Z39.50) ISBN 8467020113 2) Open URL cgi-bin/koha/unapi?id=koha:biblionumber:4&format=marcxml 3) (enter the new biblionumber for ISBN 8467020113) 4) A marcxml record will display, notice about the bad utf8 decoding characters 5) Search the record in opac and try to save in Zotero (see bad decoding) 6) To reproduce blank screen (error status) play with: cgi-bin/koha/unapi?id=koha:biblionumber:4 cgi-bin/koha/unapi?id=koha:biblionumber:4&format= cgi-bin/koha/unapi?id=koha:biblionumber:4&format=none cgi-bin/koha/unapi?id=koha:biblionumber:&format=marcxml cgi-bin/koha/unapi?&format=oai_dc cgi-bin/koha/unapi? 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8 and redirection to one of the error pages in /cgi-bin/koha/errors/
Hi Hector, I could reproduce the blank screen issue and it is resolved with your patch. Regarding the bad utf8 encoding (#4 in test plan), can you give a hint on what is wrong?
(In reply to Marc Véron from comment #3) > Hi Hector, I could reproduce the blank screen issue and it is resolved with > your patch. > > Regarding the bad utf8 encoding (#4 in test plan), can you give a hint on > what is wrong? Hi Marc, for me the patch works well, maybe I need to reword message of commit. Let me improve.
Created attachment 45427 [details] [review] Bug 15190: Bad utf8 decode to unapi and fixing blank screen error status Fix bad utf8 decoding, also fix cgi->header(-status) to redirect to one of the posible error pages in /cgi-bin/koha/errors/ To reproduce the issue in OPAC 1) Copy from LOC (Z39.50) ISBN 8467020113 or test it with whichever record with special characters 2) Open URL in OPAC cgi-bin/koha/unapi?id=koha:biblionumber:4&format=marcxml 3) Enter the new biblionumber for ISBN 8467020113 or the record of your choise 4) A marcxml record will display, notice about the bad utf8 decoding characters 5) Search the record in opac and try to save in Zotero (see bad decoding) 6) To reproduce blank screen (error status) play with: cgi-bin/koha/unapi?id=koha:biblionumber:4&format= cgi-bin/koha/unapi?id=koha:biblionumber:4&format=none cgi-bin/koha/unapi?id=koha:biblionumber:&format=marcxml cgi-bin/koha/unapi?&format=oai_dc 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) Test plan -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8 and redirection to one of the error pages in /cgi-bin/koha/errors/
(In reply to Marc Véron from comment #3) > Regarding the bad utf8 encoding (#4 in test plan), can you give a hint on > what is wrong? Ahh.. Ok I understand the deconding problem only happend with oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, rdfdc The format marcxml works well doesn't have utf8 decoding problem. <dc:title>AntologÃÂa de entremeses del Siglo de Oro /</dc:title><dc:creator> Arellano, Ignacio. </dc:creator><dc:creator> GarcÃÂa Valdés, Celsa Carmen, ed. </dc:creator> If you apply the patch <dc:title>Antología de entremeses del Siglo de Oro /</dc:title><dc:creator> Arellano, Ignacio. </dc:creator><dc:creator> García Valdés, Celsa Carmen, ed. </dc:creator> I saw the problem in 3.14 or 3.16 but I think in some way someone corrected the problem, Zotero take metadata from marcxml. Whe i was testing this bug I only tested with oai_dc, srw_dc and rdfdc. That's my mistake
Created attachment 45428 [details] [review] Bug 15190: Bad utf8 decode to unapi and fixing blank screen error status Fix bad utf8 decoding, also fix cgi->header(-status) to redirect to one of the posible error pages in /cgi-bin/koha/errors/ To reproduce the issue in OPAC 1) Copy from LOC (Z39.50) ISBN 8467020113 or test it with whichever record with special characters 2) Open URL in OPAC cgi-bin/koha/unapi?id=koha:biblionumber:4&format=oai_dc play with oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, rdfdc. Note: marcxml does not fail 3) Enter the new biblionumber for ISBN 8467020113 or the record of your choise 4) An oai_dc record will display, notice about the bad utf8 decoding characters 5) Search the record in OPAC 6) To reproduce blank screen (error status) play with: cgi-bin/koha/unapi?id=koha:biblionumber:4&format= cgi-bin/koha/unapi?id=koha:biblionumber:4&format=none cgi-bin/koha/unapi?id=koha:biblionumber:&format=oai_dc cgi-bin/koha/unapi?&format=oai_dc 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) Test plan -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8 and redirection to one of the error pages in /cgi-bin/koha/errors/
Created attachment 45432 [details] [review] Bug 15190: Bad utf8 decode to unapi and fixing blank screen error status Fix bad utf8 decoding, also fix cgi->header(-status) to redirect to one of the posible error pages in /cgi-bin/koha/errors/ To reproduce the issue in OPAC 1) Copy from LOC (Z39.50) ISBN 8467020113 or test it with whichever record with special characters 2) Open URL in OPAC cgi-bin/koha/unapi?id=koha:biblionumber:4&format=oai_dc play with oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, rdfdc. Note: marcxml does not fail 3) Enter the new biblionumber for ISBN 8467020113 or the record of your choise 4) An oai_dc record will display, notice about the bad utf8 decoding characters 5) Search the record in OPAC 6) To reproduce blank screen (error status) play with: cgi-bin/koha/unapi?id=koha:biblionumber:4&format= cgi-bin/koha/unapi?id=koha:biblionumber:4&format=none cgi-bin/koha/unapi?id=koha:biblionumber:&format=oai_dc cgi-bin/koha/unapi?&format=oai_dc 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) Test plan -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8 and redirection to one of the error pages in /cgi-bin/koha/errors/ -- Bad formatting reproduced e.g. with format=srw_dc, blank page reproduced with oai_dc, after applying patch formatting and redirect to error page OK Signed-off-by: Marc Véron <veron@veron.ch>
Looks good to me, but I don't have enough expertise in this script to be 100% confident with the changes. Galen, could we get your opinion on this patch please? I am not sure about 2 points: - replace printing header with a redirect - move error 406 to 400
Hector: Thanks for your patch. I think we still need some changes before moving this to PQA: [1] The encoding problem is imo concentrated in these lines: Around line 155 we should do: print $cgi->header( -type =>'application/xml', -charset => 'UTF-8' ); Add the character set ! (Maybe this is needed a few times more..) Around line 147 we should use chars instead of toString: # $content = $record_dom->toString(); $content = $transformer->output_as_chars( $record_dom ); According to my testing that should resolve the encoding problem. Note that I would prefer to stick to the binmode statement and not add the decodes. [2] The change from 406 to 400 is arguable. Why change it now? [3] Do not redirect to other Koha scripts. This is a separate unAPI implementation. What does unAPI exactly say about such statuses? (I could not reach its site for now..) Note that the browser may affect the results displayed too. I saw differences here between FF and IE.
http://code4lib.org/files/unapi_revision_1-14.html https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&ved=0ahUKEwjFvafUzPbJAhWCDhoKHarGDJUQFgg4MAM&url=https%3A%2F%2Fir.library.oregonstate.edu%2Fxmlui%2Fbitstream%2Fhandle%2F1957%2F2359%2Fintro-unapi-draftV15.doc%3Fsequence%3D8&usg=AFQjCNEGxssbXiRQmzUPElGJkGQd1hjx5w&bvm=bv.110151844,d.bGQ
Thank you very much, Marcel. I've changed the name of the bug according with the info you sent me. I make the changes that you recommend it. I only changed the 200 Ok status if no parameters passed to script.
Created attachment 46513 [details] [review] Bug 15190: Bad utf8 decode to unapi and fixing status code 200 Fix bad utf8 decoding, also fix status code 200 for no parameters passed to script To reproduce the issue in OPAC 1) Copy from LOC (Z39.50) ISBN 8467020113 or test it with whichever record with special characters 2) Open URL in OPAC cgi-bin/koha/unapi?id=koha:biblionumber:4&format=oai_dc play with oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, rdfdc. Note: marcxml does not fail 3) Enter the new biblionumber for ISBN 8467020113 or the record of your choise 4) An oai_dc record will display, notice about the bad utf8 decoding characters 5) Search the record in OPAC 6) To reproduce code 200 Ok and 300 Multiple choices play with: cgi-bin/koha/unapi cgi-bin/koha/unapi?id=koha:biblionumber:4 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) Test plan -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8
Great, Hector. Marc: if you can your signoff again, I can QA again..
Hi Héctor, The encoding is OK with the newest patch for example with: cgi-bin/koha/unapi?id=koha:biblionumber:45100&format=oai_dc (tested with all of: oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, rdfdc) What should happen if I do: cgi-bin/koha/unapi?id=koha:biblionumber:45100&format=xxx cgi-bin/koha/unapi?id=koha:biblionumber:45100&format= What should happen if I use a biblionumber that does not exist? cgi-bin/koha/unapi?id=koha:biblionumber:999999999&format=oai_dc At the moment I get a blank page for all cases.
(In reply to Marc Véron from comment #15) > Hi Héctor, > > The encoding is OK with the newest patch for example with: > cgi-bin/koha/unapi?id=koha:biblionumber:45100&format=oai_dc > (tested with all of: oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, > rdfdc) > > What should happen if I do: > > cgi-bin/koha/unapi?id=koha:biblionumber:45100&format=xxx > cgi-bin/koha/unapi?id=koha:biblionumber:45100&format= > > What should happen if I use a biblionumber that does not exist? > cgi-bin/koha/unapi?id=koha:biblionumber:999999999&format=oai_dc > > At the moment I get a blank page for all cases. Blank page is not an error. Unapi should return a http status code for bad requests. See comment11
(In reply to Marcel de Rooy from comment #16) Hi Marc Thank you for keep testing. As Marcel comments the way of the bug has change since the documentation in comment 11. ( I was in a mistake) > (In reply to Marc Véron from comment #15) > > What should happen if I do: > > > > cgi-bin/koha/unapi?id=koha:biblionumber:45100&format=xxx > > cgi-bin/koha/unapi?id=koha:biblionumber:45100&format= According with the first revision, the unapi must return an code status 300 multiple choice. > > What should happen if I use a biblionumber that does not exist? > > cgi-bin/koha/unapi?id=koha:biblionumber:999999999&format=oai_dc This must return a 400 or 404 code. > > > > At the moment I get a blank page for all cases. > > Blank page is not an error. Unapi should return a http status code for bad > requests. See comment11 Regards
Hi Héctor, i did more testing: cgi-bin/koha/unapi?id=koha:biblionumber:45100&format=xxx cgi-bin/koha/unapi?id=koha:biblionumber:45100&format= Result for both: 406 invalid format requested Empty page http://10.0.0.62/cgi-bin/koha/unapi?id=koha:biblionumber:999999999&format=oai_dc Result: 404 record not found Empty page http://10.0.0.62/cgi-bin/koha/unapi?id=koha:biblionumber:xxxxxxxxxxxxx&format=oai_dc Result: 404 record not found Empty page http://10.0.0.62/cgi-bin/koha/unapi?id=koha:blabla:1&format=oai_dc Result: 404 record not found Empty page http://10.0.0.62/cgi-bin/koha/unapi?id=koha:biblionumber:1xxxxxxxxxxxxx&format=oai_dc Result: 200 OK Page beginning with: oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> (...) Same as with koha:biblionumber:1 (existing number) http://10.0.0.62/cgi-bin/koha/unapi?id= Result: 300 multiple choices Page beginning with: <formats id=""><format name="marcxml" type="application/xml" (...)
Marc: This looks reasonable to me. Note that the biblionumber is extracted like this: if ($id =~ /koha:biblionumber:(\d+)/) { my $biblionumber = $1; This is current behavior and could be considered as outside the scope of this report.. The id= (empty) case is actually the same as without any parameters. So should present formats. I do not have a problem with the 406; this particular case was a 400.
Created attachment 46574 [details] [review] Bug 15190: Bad utf8 decode to unapi and fixing status code 200 Fix bad utf8 decoding, also fix status code 200 for no parameters passed to script To reproduce the issue in OPAC 1) Copy from LOC (Z39.50) ISBN 8467020113 or test it with whichever record with special characters 2) Open URL in OPAC cgi-bin/koha/unapi?id=koha:biblionumber:4&format=oai_dc play with oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, rdfdc. Note: marcxml does not fail 3) Enter the new biblionumber for ISBN 8467020113 or the record of your choise 4) An oai_dc record will display, notice about the bad utf8 decoding characters 5) Search the record in OPAC 6) To reproduce code 200 Ok and 300 Multiple choices play with: cgi-bin/koha/unapi cgi-bin/koha/unapi?id=koha:biblionumber:4 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) Test plan -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8 Followed test plan, works as expected. Signed-off-by: Marc Véron <veron@veron.ch>
Created attachment 46581 [details] [review] Bug 15190: Bad utf8 decode to unapi and fixing status code 200 Fix bad utf8 decoding, also fix status code 200 for no parameters passed to script To reproduce the issue in OPAC 1) Copy from LOC (Z39.50) ISBN 8467020113 or test it with whichever record with special characters 2) Open URL in OPAC cgi-bin/koha/unapi?id=koha:biblionumber:4&format=oai_dc play with oai_dc, srw_dc, mods, mods-full, mods3, mods3-full, rdfdc. Note: marcxml does not fail 3) Enter the new biblionumber for ISBN 8467020113 or the record of your choise 4) An oai_dc record will display, notice about the bad utf8 decoding characters 5) Search the record in OPAC 6) To reproduce code 200 Ok and 300 Multiple choices play with: cgi-bin/koha/unapi cgi-bin/koha/unapi?id=koha:biblionumber:4 7) If possible test in NORMARC (UNIMARC will launch an error because bug 15162) Test plan -Apply patch -Follow steps 2 to 6 -You will see no errors in utf8 Followed test plan, works as expected. Signed-off-by: Marc Veron <veron@veron.ch> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to Master - Should be in the May 2016 release. Thanks!
Patch pushed to 3.22.x, will be in 3.22.3
This patch has been pushed to 3.20.x, will be in 3.20.9.