File tree Expand file tree Collapse file tree
library/ZendSearch/Lucene Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,8 +67,15 @@ protected function extractMetaData(\ZipArchive $package)
6767 // Data holders
6868 $ coreProperties = array ();
6969
70+ // Prevent php from loading remote resources
71+ $ loadEntities = libxml_disable_entity_loader (true );
72+
7073 // Read relations and search for core properties
7174 $ relations = simplexml_load_string ($ package ->getFromName ("_rels/.rels " ));
75+
76+ // Restore entity loader state
77+ libxml_disable_entity_loader ($ loadEntities );
78+
7279 foreach ($ relations ->Relationship as $ rel ) {
7380 if ($ rel ["Type " ] == self ::SCHEMA_COREPROPERTIES ) {
7481 // Found core properties! Read in contents...
Original file line number Diff line number Diff line change @@ -60,7 +60,15 @@ private function __construct($fileName, $storeContent)
6060 if ($ relationsXml === false ) {
6161 throw new RuntimeException ('Invalid archive or corrupted .docx file. ' );
6262 }
63+
64+ // Prevent php from loading remote resources
65+ $ loadEntities = libxml_disable_entity_loader (true );
66+
6367 $ relations = simplexml_load_string ($ relationsXml );
68+
69+ // Restore entity loader state
70+ libxml_disable_entity_loader ($ loadEntities );
71+
6472 foreach ($ relations ->Relationship as $ rel ) {
6573 if ($ rel ["Type " ] == AbstractOpenXML::SCHEMA_OFFICEDOCUMENT ) {
6674 // Found office document! Read in contents...
Original file line number Diff line number Diff line change @@ -80,7 +80,15 @@ private function __construct($fileName, $storeContent)
8080 if ($ relationsXml === false ) {
8181 throw new RuntimeException ('Invalid archive or corrupted .pptx file. ' );
8282 }
83+
84+ // Prevent php from loading remote resources
85+ $ loadEntities = libxml_disable_entity_loader (true );
86+
8387 $ relations = simplexml_load_string ($ relationsXml );
88+
89+ // Restore entity loader state
90+ libxml_disable_entity_loader ($ loadEntities );
91+
8492 foreach ($ relations ->Relationship as $ rel ) {
8593 if ($ rel ["Type " ] == AbstractOpenXML::SCHEMA_OFFICEDOCUMENT ) {
8694 // Found office document! Search for slides...
Original file line number Diff line number Diff line change @@ -89,7 +89,15 @@ private function __construct($fileName, $storeContent)
8989 if ($ relationsXml === false ) {
9090 throw new RuntimeException ('Invalid archive or corrupted .xlsx file. ' );
9191 }
92+
93+ // Prevent php from loading remote resources
94+ $ loadEntities = libxml_disable_entity_loader (true );
95+
9296 $ relations = simplexml_load_string ($ relationsXml );
97+
98+ // Restore entity loader state
99+ libxml_disable_entity_loader ($ loadEntities );
100+
93101 foreach ($ relations ->Relationship as $ rel ) {
94102 if ($ rel ["Type " ] == AbstractOpenXML::SCHEMA_OFFICEDOCUMENT ) {
95103 // Found office document! Read relations for workbook...
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ public static function getPrefix($str, $length)
7575 */
7676 $ prefixBytes = 0 ;
7777 $ prefixChars = 0 ;
78- while ($ prefixBytes < strlen ($ str ) && $ prefixChars < $ length ) {
78+ while (isset ($ str[ $ prefixBytes ] ) && $ prefixChars < $ length ) {
7979 $ charBytes = 1 ;
8080 if ((ord ($ str [$ prefixBytes ]) & 0xC0 ) == 0xC0 ) {
8181 $ charBytes ++;
@@ -87,7 +87,7 @@ public static function getPrefix($str, $length)
8787 }
8888 }
8989
90- if ($ prefixBytes + $ charBytes > strlen ( $ str )) {
90+ if (! isset ( $ str [ $ prefixBytes + $ charBytes - 1 ] )) {
9191 // wrong character
9292 break ;
9393 }
You can’t perform that action at this time.
0 commit comments