[icinga-checkins] icinga.org: icinga-web/r1.7: Bugfix for html entities in cronk params

git at icinga.org git at icinga.org
Fri Oct 5 10:31:56 CEST 2012


Module: icinga-web
Branch: r1.7
Commit: cf4d2a6d015ff002ff5bc0a7072a0e2d41d439e2
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=cf4d2a6d015ff002ff5bc0a7072a0e2d41d439e2

Author: Marius Hein <marius.hein at netways.de>
Date:   Fri Oct  5 09:58:58 2012 +0200

Bugfix for html entities in cronk params

Needed for the cronk builder, fixes #3062

Conflicts:

	app/modules/Cronks/models/Provider/CronksDataModel.class.php

---

 .../models/Provider/CronksDataModel.class.php      |    6 +++-
 .../phpunit/tests/regression/bugs/Bug3062Test.php  |   33 ++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/app/modules/Cronks/models/Provider/CronksDataModel.class.php b/app/modules/Cronks/models/Provider/CronksDataModel.class.php
index 2619a7e..d7e4264 100644
--- a/app/modules/Cronks/models/Provider/CronksDataModel.class.php
+++ b/app/modules/Cronks/models/Provider/CronksDataModel.class.php
@@ -450,7 +450,11 @@ class Cronks_Provider_CronksDataModel extends CronksBaseModel implements AgaviIS
                 if (is_array($value)) {
 
                     foreach($value as $sn=>$sv) {
-                        $se = $dom->createElement('ae:parameter', $sv);
+                        // To avoid "unterminated entity reference" warnings /
+                        // exceptions, putt all into cdata section
+                        $cdata = $dom->createCDATASection($sv);
+                        $se = $dom->createElement('ae:parameter');
+                        $se->appendChild($cdata);
                         $se->setAttribute('name', $sn);
                         $ele->appendChild($se);
                     }
diff --git a/tests/phpunit/tests/regression/bugs/Bug3062Test.php b/tests/phpunit/tests/regression/bugs/Bug3062Test.php
new file mode 100644
index 0000000..d9c3cee
--- /dev/null
+++ b/tests/phpunit/tests/regression/bugs/Bug3062Test.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Test case for https://dev.icinga.org/issues/3062
+ */
+class Bug3062Test extends PHPUnit_Framework_TestCase {
+    
+    public function testBug() {
+        static $cronk_name = 'Bug3062Test_Cronk_Record';
+        $ctx = IcingaWebTestTool::getContext();
+        
+        $model = $ctx->getModel('Provider.CronksData', 'Cronks');
+        
+        $testCronkData = array(
+            'cid'           => $cronk_name,
+            'name'          => $cronk_name,
+            'description'   => $cronk_name,
+            'categories'    => 'my',
+            'ae:parameter' => array(
+                'entity1'   => 'd=1&d=2&d=3',
+                'entity2'   => '<a></a>',
+                'entity3'   => '"a", \'b\''
+            )
+        );
+        
+        $record = $model->createCronkRecord($testCronkData);
+        
+        $this->assertInstanceOf('Cronk', $record);
+        $this->assertEquals($cronk_name, $record->cronk_uid);
+        $this->assertEquals($cronk_name, $record->cronk_name);
+    }
+    
+}
\ No newline at end of file





More information about the icinga-checkins mailing list