Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/60798
Change subject: Add input checks for Language::sprintfDate()
......................................................................
Add input checks for Language::sprintfDate()
Check if the timestamp has a length of 14 characters and if it is numeric.
Throw an exception otherwise.
Bug: 47629
Change-Id: I9a4fd0af88cf20c2a6bd72fd7048743466c1600f
---
M languages/Language.php
1 file changed, 10 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/98/60798/1
diff --git a/languages/Language.php b/languages/Language.php
index 9651f3d..40aed01 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -1078,6 +1078,7 @@
* @param $zone DateTimeZone: Timezone of $ts
* @todo handling of "o" format character for Iranian, Hebrew, Hijri &
Thai?
*
+ * @throws MWException
* @return string
*/
function sprintfDate( $format, $ts, DateTimeZone $zone = null ) {
@@ -1093,6 +1094,15 @@
$thai = false;
$minguo = false;
$tenno = false;
+
+ if( !strlen( $ts ) === 14 ) {
+ throw new MWException( __METHOD__ . ":XXX The timestamp
$ts should have 14 characters" );
+ }
+
+ if( !is_numeric( $ts ) ) {
+ throw new MWException( __METHOD__ . ": The timestamp
$ts should be a number" );
+ }
+
for ( $p = 0; $p < strlen( $format ); $p++ ) {
$num = false;
$code = $format[$p];
--
To view, visit https://gerrit.wikimedia.org/r/60798
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a4fd0af88cf20c2a6bd72fd7048743466c1600f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits