Gerrit Patch Uploader has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381616 )

Change subject: T177134: Nulls passed to preg_match in Cite
......................................................................

T177134: Nulls passed to preg_match in Cite

Line 334 of Cite/includes/Cite.php contains two preg_match () calls. The 
subject lines for them are produced by Cite::refArgs () and are set to null or 
false when no name or follow attribute is provided in the <ref></ref> tag.

However, preg_match () is supposed to accept only strings as its subject, and 
the nowhere in the documentation it is said that it is nullable.

At least, in HHVM 3.12 this causes an exception.

The enclosed patch add simple checks making sure that preg_match () is not 
called when $key or $follow are null or false.

Change-Id: I3e00d31d6bf216271ace7e851d88c68c4fd5ed00
---
M includes/Cite.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cite 
refs/changes/16/381616/1

diff --git a/includes/Cite.php b/includes/Cite.php
index 69a0f99..237b9cc 100644
--- a/includes/Cite.php
+++ b/includes/Cite.php
@@ -331,7 +331,7 @@
                        return $this->error( 'cite_error_ref_no_key' );
                }
 
-               if ( preg_match( '/^[0-9]+$/', $key ) || preg_match( 
'/^[0-9]+$/', $follow ) ) {
+               if ( $key && preg_match( '/^[0-9]+$/', $key ) || $follow && 
preg_match( '/^[0-9]+$/', $follow ) ) {
                        # Numeric names mess up the resulting id's, potentially 
produ-
                        # cing duplicate id's in the XHTML.  The Right Thing To 
Do
                        # would be to mangle them, but it's not really 
high-priority

-- 
To view, visit https://gerrit.wikimedia.org/r/381616
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e00d31d6bf216271ace7e851d88c68c4fd5ed00
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cite
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Alexander I. Mashin <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to