Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/248539
Change subject: Escape colons in BagOStuff key segments
......................................................................
Escape colons in BagOStuff key segments
For the sake of safety and correctnes, the following BagOStuff::makeKey()
invocations should return distinct keys:
$cache->makeKey( 'ab:', 'cd' );
$cache->makeKey( 'ab', ':cd' );
That is not currently the case, because while we use ':' as a key path
separator, we don't escape ':' in the input supplied to makeKey().
Change-Id: I83ea7e7336a1c9e64aa42284c2517089a736efe5
---
M includes/libs/objectcache/BagOStuff.php
M tests/phpunit/includes/objectcache/BagOStuffTest.php
2 files changed, 10 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/39/248539/1
diff --git a/includes/libs/objectcache/BagOStuff.php
b/includes/libs/objectcache/BagOStuff.php
index c3c357f..26c87d5 100644
--- a/includes/libs/objectcache/BagOStuff.php
+++ b/includes/libs/objectcache/BagOStuff.php
@@ -627,7 +627,11 @@
* @return string
*/
public function makeKeyInternal( $keyspace, $args ) {
- $key = $keyspace . ':' . implode( ':', $args );
+ $key = $keyspace;
+ foreach ( $args as $arg ) {
+ $arg = strtr( $arg, ':', '%3A' );
+ $key = $key . ':' . $arg;
+ }
return strtr( $key, ' ', '_' );
}
diff --git a/tests/phpunit/includes/objectcache/BagOStuffTest.php
b/tests/phpunit/includes/objectcache/BagOStuffTest.php
index 466b9f5..94b74cb 100644
--- a/tests/phpunit/includes/objectcache/BagOStuffTest.php
+++ b/tests/phpunit/includes/objectcache/BagOStuffTest.php
@@ -50,6 +50,11 @@
$globalKey,
'Local key and global key with same parameters should
not be equal'
);
+
+ $this->assertNotEquals(
+ $cache->makeKeyInternal( 'prefix', array( 'a', 'bc:',
'de' ) ),
+ $cache->makeKeyInternal( 'prefix', array( 'a', 'bc',
':de' ) )
+ );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/248539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I83ea7e7336a1c9e64aa42284c2517089a736efe5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits