Add in-memory caching strategy for shared strings

In-memory implementation using SplFixedArray
Updated code and tests to support errors when reading XML nodes (useful when reading XML files used for attacks)
Removed LIBXML_NOENT option (which DOES substitute entities...)
Added test for Quadratic Blowup attack
This commit is contained in:
Adrien Loison committed 2015-07-13 00:29:59 -07:00
1 parent 2dcb86aae9
commit 334f7087da
9 files changed
+199 -57

No files matched your search

@@ -28,9 +28,13 @@ class CachingStrategyFactory
* @param string|void $tempFolder Temporary folder where the temporary files to store shared strings will be stored
* @return CachingStrategyInterface The best caching strategy
*/
public function getBestCachingStrategy($sharedStringsUniqueCount, $tempFolder = null)
public static function getBestCachingStrategy($sharedStringsUniqueCount, $tempFolder = null)
{
// TODO add in-memory strategy
return new FileBasedStrategy($tempFolder, self::MAX_NUM_STRINGS_PER_TEMP_FILE);
// TODO: take available memory into account
if ($sharedStringsUniqueCount < self::MAX_NUM_STRINGS_PER_TEMP_FILE) {
return new InMemoryStrategy($sharedStringsUniqueCount);
} else {
return new FileBasedStrategy($tempFolder, self::MAX_NUM_STRINGS_PER_TEMP_FILE);
}
}
}