File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -890,7 +890,7 @@ public function prepareInputForAdd($input) {
890890 }
891891
892892 try {
893- $ input ['name ' ] = $ DB -> escape ( $ this ->parseTags ($ form ->fields ['formanswer_name ' ]) );
893+ $ input ['name ' ] = $ this ->parseTags ($ form ->fields ['formanswer_name ' ]);
894894 } catch (Exception $ e ) {
895895 // A fatal error caught during parsing of tags
896896 $ GLPI ->getErrorHandler ()->handleException ($ e , false );
Original file line number Diff line number Diff line change @@ -621,20 +621,15 @@ protected function getTargetTemplate(array $data): int {
621621 'FROM ' => ITILCategory::getTable (),
622622 'WHERE ' => ['id ' => $ data ['itilcategories_id ' ]]
623623 ]);
624- if ($ row = $ rows ->current ()) { // assign change template according to resulting change category
624+ if ($ row = $ rows ->current ()) {
625+ // assign change template according to resulting change category
625626 return $ row [$ targetTemplateFk ];
626627 }
627628 }
628629
629630 return $ this ->fields [$ targetTemplateFk ] ?? 0 ;
630631 }
631632
632- public function getDefaultData (PluginFormcreatorFormAnswer $ formanswer ): array {
633- $ data = parent ::getDefaultData ($ formanswer );
634-
635- return $ data ;
636- }
637-
638633 /**
639634 * Save form data to the target
640635 *
Original file line number Diff line number Diff line change @@ -803,20 +803,15 @@ protected function getTargetTemplate(array $data): int {
803803 'FROM ' => ITILCategory::getTable (),
804804 'WHERE ' => ['id ' => $ data ['itilcategories_id ' ]]
805805 ]);
806- if ($ row = $ rows ->current ()) { // assign ticket template according to resulting ticket category and ticket type
806+ if ($ row = $ rows ->current ()) {
807+ // assign ticket template according to resulting ticket category and ticket type
807808 return ($ data ['type ' ] == Ticket::INCIDENT_TYPE
808809 ? $ row ["{$ targetTemplateFk }_incident " ]
809810 : $ row ["{$ targetTemplateFk }_demand " ]);
810811 }
811812 }
812813
813- return $ this ->fields ['tickettemplates_id ' ] ?? 0 ;
814- }
815-
816- public function getDefaultData (PluginFormcreatorFormAnswer $ formanswer ): array {
817- $ data = parent ::getDefaultData ($ formanswer );
818-
819- return $ data ;
814+ return $ this ->fields [$ targetTemplateFk ] ?? 0 ;
820815 }
821816
822817 /**
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ public function isResyncIssuesRequired() {
4646 public function upgrade (Migration $ migration ) {
4747 $ this ->migration = $ migration ;
4848 $ this ->migrateToRichText ();
49+ $ this ->sanitizeConditions ();
4950 }
5051
5152 public function migrateToRichText () {
@@ -82,4 +83,24 @@ public function migrateToRichText() {
8283 }
8384 }
8485 }
86+
87+ /**
88+ * Conditions written in Formcreator < 2.13.0 are not sanitized.
89+ * With versions >= 2.13.0, comparisons require sanitization
90+ *
91+ * @return void
92+ */
93+ protected function sanitizeConditions () {
94+ global $ DB ;
95+
96+ $ table = 'glpi_plugin_formcreator_conditions ' ;
97+ $ request = $ DB ->request ([
98+ 'SELECT ' => ['id ' , 'show_value ' ],
99+ 'FROM ' => $ table ,
100+ ]);
101+ foreach ($ request as $ row ) {
102+ $ row ['show_value ' ] = Sanitizer::sanitize ($ row ['show_value ' ], true );
103+ $ DB ->update ($ table , $ row , ['id ' => $ row ['id ' ]]);
104+ }
105+ }
85106}
You can’t perform that action at this time.
0 commit comments