Skip to content

Commit

Permalink
remove unallowed characters in SCORM manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe-Kohnle committed Feb 14, 2024
1 parent 65715fe commit b2cfc9b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Modules/Scorm2004/classes/class.ilSCORM13MDImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct($a_manifest_dom, $a_obj_id)
*/
public function setTitle($a_val)
{
$this->title = $a_val;
$this->title = ilUtil::stripSlashes($a_val);
}

/**
Expand All @@ -57,7 +57,7 @@ public function setTitle($a_val)
*/
public function getTitle()
{
return $this->title;
return ilUtil::stripSlashes($this->title);
}

/**
Expand All @@ -67,7 +67,7 @@ public function getTitle()
*/
public function setDescription($a_val)
{
$this->description = $a_val;
$this->description = ilUtil::stripSlashes($a_val);
}

/**
Expand All @@ -77,7 +77,7 @@ public function setDescription($a_val)
*/
public function getDescription()
{
return $this->description;
return ilUtil::stripSlashes($this->description);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions Modules/Scorm2004/classes/ilSCORM13Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ public function il_import($packageFolder, $packageId, $ilias, $validate, $reimpo
$j['base'] = $packageFolder . '/';
$j['foreignId'] = floatval($x['foreignId']); // manifest cp_node_id for associating global (package wide) objectives
$j['id'] = strval($x['id']); // manifest id for associating global (package wide) objectives
$j['item']['title'] = ilUtil::stripSlashes($j['item']['title']);
for ($i = 0; $i < count($j['item']['item']); $i++) {
$j['item']['item'][$i]['title'] = ilUtil::stripSlashes($j['item']['item'][$i]['title']);
}


//last step - build ADL Activity tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,14 @@ public function handlerCharacterData($a_xml_parser, $a_data)
switch ($this->getAncestorElement(1)) {
case "organization":
$this->current_organization->setTitle(
$this->current_organization->getTitle() . $a_data
ilUtil::stripSlashes($this->current_organization->getTitle() . $a_data)
);
$this->package_title = $this->current_organization->getTitle();
$this->package_title = ilUtil::stripSlashes($this->current_organization->getTitle());
break;

case "item":
$this->item_stack[count($this->item_stack) - 1]->setTitle(
$this->item_stack[count($this->item_stack) - 1]->getTitle() . $a_data
ilUtil::stripSlashes($this->item_stack[count($this->item_stack) - 1]->getTitle() . $a_data)
);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ public function uploadObject()
$name = $this->lng->txt("no_title");
}

$description = "";

$subType = $_POST["sub_type"];

// always import authoring packages as scorm2004, see bug #27801
Expand Down Expand Up @@ -486,6 +488,8 @@ public function uploadObject()
// $newObj->setImportSequencing($_POST["import_sequencing"]);
// $newObj->setSequencingExpertMode($_POST["import_sequencing"]);
}
$name = $mprops['Title'];
$description = $mprops['Description'];
} else {
ilUtil::delDir($lmTempDir, false);
ilUtil::sendFailure($this->lng->txt("import_file_not_valid"), true);
Expand All @@ -497,7 +501,7 @@ public function uploadObject()

$newObj->setTitle($name);
$newObj->setSubType($subType);
$newObj->setDescription("");
$newObj->setDescription($description);
$newObj->setOfflineStatus(true);
$newObj->create(true);
$newObj->createReference();
Expand Down
10 changes: 5 additions & 5 deletions Modules/ScormAicc/classes/class.ilScormAiccDataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ilScormAiccDataSet extends ilDataSet
/**
* @var string[][]
*/
public $properties = [
public $properties = [
//"OfflineZipCreated" => "datetime",
"Id" => ["db_col" => "id", "db_type" => "integer"],
//"EntryPage" => "integer",
Expand Down Expand Up @@ -168,7 +168,7 @@ public function writeData($a_entity, $a_version, $a_id, $data = [])
$od_columns [$value["db_col"]] = [$value["db_type"], $data[$key]];
}

if (count($od_columns) > 0) {
if (isset($od_columns) && count($od_columns) > 0) {
$od_conditions ["obj_id"] = ["integer", $a_id];
$ilDB->update("object_data", $od_columns, $od_conditions);
}
Expand Down Expand Up @@ -214,8 +214,8 @@ public function getExtendedXmlRepresentation($a_entity, $a_schema_version, int $
$id = $this->data["id"];

// requirements
require_once( dirname(__DIR__,3) . "/Services/Export/classes/class.ilExport.php");
require_once(dirname(__DIR__,3) . "/Services/Xml/classes/class.ilXmlWriter.php");
require_once(dirname(__DIR__, 3) . "/Services/Export/classes/class.ilExport.php");
require_once(dirname(__DIR__, 3) . "/Services/Xml/classes/class.ilXmlWriter.php");


// prepare archive skeleton
Expand Down Expand Up @@ -395,7 +395,7 @@ private function buildProperties($a_entity, $a_omit_header = false)

foreach ($this->data as $key => $value) {
$writer->xmlElement($this->getElementNameByDbColumn($key), null, $value, true, true);
$writer->appendXML("\n");
$writer->appendXML("\n");
}

$writer->xmlEndTag("DataSet");
Expand Down
2 changes: 2 additions & 0 deletions Modules/ScormAicc/classes/class.ilScormAiccImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public function importXmlRepresentation($a_entity, $a_id, $a_import_dirname, $a_
foreach ($this->dataset->properties as $key => $value) {
$this->moduleProperties[$key] = $xmlRoot->$key;
}
$this->moduleProperties["Title"] = $xmlRoot->Title;
$this->moduleProperties["Description"] = $xmlRoot->Description;

foreach ($this->moduleProperties as $key => $xmlRoot) {
$xmlRootValue = $xmlRoot->__toString();
Expand Down

0 comments on commit b2cfc9b

Please sign in to comment.