diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..ae118d7
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,17 @@
+version: '2'
+services:
+ php56:
+ image: fpfis/php56-dev
+ volumes:
+ - .:/var/www/html
+ environment:
+ XDEBUG_CONFIG: "remote_enable=1 remote_host=${DOCKER_HOST_IP} remote_port=9000 idekey=PHPSTORM remote_autostart=1"
+ PHP_IDE_CONFIG: "serverName=Test"
+
+ php71:
+ image: fpfis/php71-dev
+ volumes:
+ - .:/var/www/html
+ environment:
+ XDEBUG_CONFIG: "remote_enable=1 remote_host=${DOCKER_HOST_IP} remote_port=9000 idekey=PHPSTORM remote_autostart=1"
+ PHP_IDE_CONFIG: "serverName=Test"
diff --git a/src/Messages/Components/Details.php b/src/Messages/Components/Details.php
index fb04d37..b80508c 100644
--- a/src/Messages/Components/Details.php
+++ b/src/Messages/Components/Details.php
@@ -391,18 +391,19 @@ protected function parseXml($xml)
->setApplicationId($parser->getContent('demande/applicationReference'))
->setAuthor($parser->getContent('demande/organisationAuteur'))
->setRequester($parser->getContent('demande/serviceDemandeur'))
+ ->setResponsible($parser->getContent('demande/organisationResponsable'))
->setTitle($parser->getContent('demande/titre'))
->setRemark($parser->getContent('demande/remarque'))
- ->setType($parser->getContent('demande/type'))
->setWorkflowCode($parser->getContent('demande/workflowCode'))
- ->setDestination($parser->getContent('demande/destination'))
- ->setProcedure($parser->getContent('demande/procedure'))
+ ->setProcedure($parser->getAttribute('demande/procedure', 'id'))
+ ->setDestination($parser->getAttribute('demande/destination', 'id'))
+ ->setType($parser->getAttribute('demande/type', 'id'))
->setDelay($parser->getContent('demande/delai'))
->setRequestDate($parser->getContent('demande/dateDemande'))
->setStatus($parser->getContent('demande/statusDemande'))
->setInterServices($parser->getContent('demande/consultationInterServices'))
->setInterInstitution($parser->getContent('demande/procedureInterInstitution'))
- ->setReferenceFilesRemark($parser->getContent('demande/reference_files_note'));
+ ->setReferenceFilesRemark($parser->getContent('demande/referenceFilesNote'));
return $this;
}
diff --git a/src/Services/Plates/AttributesExtension.php b/src/Services/Plates/AttributesExtension.php
index 3680133..7d24780 100644
--- a/src/Services/Plates/AttributesExtension.php
+++ b/src/Services/Plates/AttributesExtension.php
@@ -37,9 +37,18 @@ public function render(array $attributes)
{
$renderedAttributes = [];
foreach ($attributes as $key => $value) {
- $renderedAttributes[] = $key.'="'.htmlspecialchars($value, ENT_XML1).'"';
+ $renderedAttributes[] = $key.'="'.$this->escape($value).'"';
}
return implode(' ', $renderedAttributes);
}
+
+ /**
+ * @param string $string
+ * @return string
+ */
+ public function escape($string)
+ {
+ return htmlspecialchars($string, ENT_XML1 | ENT_COMPAT, 'UTF-8');
+ }
}
diff --git a/templates/components/details.tpl.php b/templates/components/details.tpl.php
index eea355c..395c737 100644
--- a/templates/components/details.tpl.php
+++ b/templates/components/details.tpl.php
@@ -15,48 +15,48 @@
getTitle() ?>]]>
getResponsible()) : ?>
- = $component->getResponsible() ?>
+ getResponsible() ?>]]>
getAuthor()) : ?>
- = $component->getAuthor() ?>
+ getAuthor() ?>]]>
getRequester()) : ?>
- = $component->getRequester() ?>
+ getRequester() ?>]]>
getApplicationId()) : ?>
- = $component->getApplicationId() ?>
+ getApplicationId() ?>]]>
getRemark()) : ?>
getRemark() ?>]]>
getDelay()) : ?>
- = $component->getDelay() ?>
+ getDelay() ?>]]>
getRequestDate()) : ?>
- = $component->getRequestDate() ?>
+ getRequestDate() ?>]]>
getStatus()) : ?>
- = $component->getStatus() ?>
+ getStatus() ?>]]>
getInterServices()) : ?>
- = $component->getInterServices() ?>
+ getInterServices() ?>]]>
getInterInstitution()) : ?>
- = $component->getInterInstitution() ?>
+ getInterInstitution() ?>]]>
getReferenceFilesRemark()) : ?>
getReferenceFilesRemark() ?>]]>
getProcedure()) : ?>
-
+
getDestination()) : ?>
-
+
getType()) : ?>
-
+
getWorkflowCode()) : ?>
- = $component->getWorkflowCode() ?>
+ getWorkflowCode() ?>]]>
diff --git a/tests/src/SanitizationTest.php b/tests/src/SanitizationTest.php
new file mode 100644
index 0000000..ae1fa87
--- /dev/null
+++ b/tests/src/SanitizationTest.php
@@ -0,0 +1,53 @@
+get('component.'.$name);
+
+ foreach ($setters as $setter => $value) {
+ $component->$setter($value);
+ }
+
+ $xml = $poetry->getRenderEngine()->render($component->getTemplate(), [
+ 'component' => $component,
+ ]);
+
+ $actual = $poetry->get('component.'.$name)->fromXml($xml);
+ // If XML is not valid test will fail here.
+ $xml = new \SimpleXMLElement($xml);
+ foreach ($getters as $getter => $value) {
+ expect($actual->$getter($value))->to->equal($value);
+ }
+ }
+
+ /**
+ * @return array
+ */
+ public function dataProvider()
+ {
+ return Yaml::parse($this->getFixture('sanitization.yml'));
+ }
+}
diff --git a/tests/src/fixtures/arrays/components/details.yml b/tests/src/fixtures/arrays/components/details.yml
index 4505b0b..9528a79 100644
--- a/tests/src/fixtures/arrays/components/details.yml
+++ b/tests/src/fixtures/arrays/components/details.yml
@@ -15,7 +15,7 @@
inter_services: "Yes"
inter_institution: "Yes"
reference_files_remark: "Note"
- workflowCode: "STS"
+ workflow_code: "STS"
expected:
getClientId: "clientId"
getApplicationId: "applicationId"
diff --git a/tests/src/fixtures/parsers/components/details.yml b/tests/src/fixtures/parsers/components/details.yml
index 2f0bd1a..54ea97b 100644
--- a/tests/src/fixtures/parsers/components/details.yml
+++ b/tests/src/fixtures/parsers/components/details.yml
@@ -7,15 +7,15 @@
DGCOMM
Title
Remark
- INTER
- AUTRE
- NEANT
+
+
+
11/12/2007
11/12/2007
Ready
Yes
Yes
- Note
+ Note
STS
- getClientId : "clientId"
diff --git a/tests/src/fixtures/sanitization.yml b/tests/src/fixtures/sanitization.yml
new file mode 100644
index 0000000..8018d78
--- /dev/null
+++ b/tests/src/fixtures/sanitization.yml
@@ -0,0 +1,37 @@
+- component: details
+ setters:
+ setClientId: ""
+ setResponsible: ""
+ setApplicationId: "applicationId"
+ setAuthor: "DIGIT \ <> "
+ setRequester: "DGCOMM \\<>"
+ setTitle: "Title > <"
+ setRemark: "Remark!!{}"
+ setType: "INTER*^%(#"
+ setDestination: "AUTRE{}<[[]]"
+ setProcedure: "NEANT"
+ setDelay: "11/12/\\2007"
+ setRequestDate: "11\/12/2007"
+ setStatus: "Ready!><"
+ setInterServices: ""
+ setReferenceFilesRemark: "<<>>"
+ setWorkflowCode: "!!STS"
+ getters:
+ getClientId: ""
+ getResponsible: ""
+ getApplicationId: "applicationId"
+ getAuthor: "DIGIT \ <> "
+ getRequester: "DGCOMM \\<>"
+ getTitle: "Title > <"
+ getRemark: "Remark!!{}"
+ getType: "INTER*^%(#"
+ getDestination: "AUTRE{}<[[]]"
+ getProcedure: "NEANT"
+ getDelay: "11/12/\\2007"
+ getRequestDate: "11\/12/2007"
+ getStatus: "Ready!><"
+ getInterServices: ""
+ getReferenceFilesRemark: "<<>>"
+ getWorkflowCode: "!!STS"