Skip to content

Commit

Permalink
Merge pull request #1492 from gabrieljenik/bug/16498-Cant-run-survey-…
Browse files Browse the repository at this point in the history
…with-child-theme-because-of-enheritance-problems

Fixed issue #16498: Can't run survey with child theme because of enheritance problems.
  • Loading branch information
eddylackmann committed Jul 23, 2020
2 parents b033d2a + 00f6b27 commit bfb947a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions application/models/TemplateConfig.php
Expand Up @@ -1030,7 +1030,7 @@ public static function importManifest($sTemplateName, $aDatas)
$oNewTemplateConfiguration->cssframework_name = $aDatas['cssframework_name'];
$oNewTemplateConfiguration->cssframework_css = self::formatToJsonArray($aDatas['cssframework_css']);
$oNewTemplateConfiguration->cssframework_js = self::formatToJsonArray($aDatas['cssframework_js']);
$oNewTemplateConfiguration->options = self::formatToJsonArray($aDatas['aOptions']);
$oNewTemplateConfiguration->options = self::formatToJsonArray($aDatas['aOptions'], true);
$oNewTemplateConfiguration->packages_to_load = self::formatToJsonArray($aDatas['packages_to_load']);


Expand All @@ -1055,9 +1055,10 @@ public static function importManifest($sTemplateName, $aDatas)
* Convert the values to a json.
* It checks that the correct values is inserted.
* @param array|object $oFiled the filed to convert
* @param boolean $bConvertEmptyToString formats empty values as empty strings instead of objects.
* @return string json
*/
public static function formatToJsonArray($oFiled)
public static function formatToJsonArray($oFiled, $bConvertEmptyToString = false)
{
// encode then decode will convert the SimpleXML to a normal object
$jFiled = json_encode($oFiled);
Expand All @@ -1074,7 +1075,8 @@ public static function formatToJsonArray($oFiled)
}
}


// Converts empty objects to empty strings
if ($bConvertEmptyToString) $jFiled = str_replace('{}','""',$jFiled);

return $jFiled;
}
Expand Down
8 changes: 7 additions & 1 deletion application/models/TemplateManifest.php
Expand Up @@ -1008,7 +1008,13 @@ private function readManifest()
if (file_exists(realpath($this->xmlFile))) {
$bOldEntityLoaderState = libxml_disable_entity_loader(true); // @see: http://phpsecurity.readthedocs.io/en/latest/Injection-Attacks.html#xml-external-entity-injection
$sXMLConfigFile = file_get_contents(realpath($this->xmlFile)); // @see: Now that entity loader is disabled, we can't use simplexml_load_file; so we must read the file with file_get_contents and convert it as a string
$oXMLConfig = simplexml_load_string($sXMLConfigFile);
$oDOMConfig = new DOMDocument;
$oDOMConfig->loadXML($sXMLConfigFile);
$oXPath = new DOMXpath($oDOMConfig);
foreach ($oXPath->query('//comment()') as $oComment) {
$oComment->parentNode->removeChild($oComment);
}
$oXMLConfig = simplexml_import_dom($oDOMConfig);
foreach ($oXMLConfig->config->xpath("//file") as $oFileName) {
$oFileName[0] = get_absolute_path($oFileName[0]);
}
Expand Down

0 comments on commit bfb947a

Please sign in to comment.