KarenEddy has submitted this change and it was merged.
Change subject: Critical Update: Fixes an infinite loop in an xml parsing
function.
......................................................................
Critical Update:
Fixes an infinite loop in an xml parsing function.
Change-Id: I54303300c0442cf1beefc391a182e68b6485ad04
(cherry picked from commit 1f077732a1267c44104985ba3f10132811bbc249)
---
M BiblioPlus.body.php
1 file changed, 16 insertions(+), 16 deletions(-)
Approvals:
KarenEddy: Verified; Looks good to me, approved
diff --git a/BiblioPlus.body.php b/BiblioPlus.body.php
index 88ebdfb..f77d592 100644
--- a/BiblioPlus.body.php
+++ b/BiblioPlus.body.php
@@ -182,17 +182,14 @@
*/
function parsePubMed( $pmXml ) {
$formattedRefs = array();
-
$xml = simplexml_load_string( $pmXml );
if ( $xml ) {
// find the document summary tags
$docSums = $xml;
- while ( $docSums->getName() != 'DocumentSummary' ) {
- $docSums = $docSums->children();
- }
+ $docSums = $docSums->xpath('//DocumentSummary');
- // extract required information from each document summary
+ // extract required information from each document summary
foreach ( $docSums as $docSum ) {
$authors = array();
@@ -200,10 +197,12 @@
$pmid = ( string )$docSum['uid'];
// get the list of authors
- foreach ( $docSum->Authors->children() as $author ) {
- $authors[] = $author->Name;
- }
- $authors = $this->concatAuthors( $authors );
+ if ( $docSum->Authors ) {
+ foreach ( $docSum->Authors->children()
as $author ) {
+ $authors[] = $author->Name;
+ }
+ $authors = $this->concatAuthors(
$authors );
+ }
// get the other attributes
$title = $docSum->Title;
@@ -214,13 +213,14 @@
$pages = $docSum->Pages;
$doi = '';
- foreach ( $docSum->ArticleIds->children() as $articleId ) {
- if ( $articleId->IdType == 'doi' ) {
- $doi = $articleId->Value;
- break;
- }
- }
-
+ if ( $docSum->ArticleIds ) {
+ foreach (
$docSum->ArticleIds->children() as $articleId ) {
+ if ( $articleId->IdType ==
'doi' ) {
+ $doi =
$articleId->Value;
+ break;
+ }
+ }
+ }
// format for output to page
$origin = "$source $pubDate";
$origin .= $volume == '' ? '' : ";$volume";
--
To view, visit https://gerrit.wikimedia.org/r/72685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I54303300c0442cf1beefc391a182e68b6485ad04
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BiblioPlus
Gerrit-Branch: master
Gerrit-Owner: KarenEddy <[email protected]>
Gerrit-Reviewer: Acrida <[email protected]>
Gerrit-Reviewer: KarenEddy <[email protected]>
Gerrit-Reviewer: Owora <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits