Commit 37df20fd45073f1bdd3cf742e55b6fbd65adcf83
1 parent
40088d7c
Merged in from STABLE trunk...
KTS-3653 "CLONE -Advanced search not working (SUP-1023)" Fixed. Newlines in descriptions or fields would break the javascript. Committed By: Conrad Vermeulen Reviewed By: Megan Waston git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.3a-Release-Branch@9203 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
25 additions
and
20 deletions
search2/search/search.inc.php
| @@ -6,31 +6,31 @@ | @@ -6,31 +6,31 @@ | ||
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2008 KnowledgeTree Inc. | 7 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | 9 | + * |
| 10 | * This program is free software; you can redistribute it and/or modify it under | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | * the terms of the GNU General Public License version 3 as published by the | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | * Free Software Foundation. | 12 | * Free Software Foundation. |
| 13 | - * | 13 | + * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | * details. | 17 | * details. |
| 18 | - * | 18 | + * |
| 19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | ||
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | 21 | + * |
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | * California 94120-7775, or email info@knowledgetree.com. | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | 24 | + * |
| 25 | * The interactive user interfaces in modified source and object code versions | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | * of this program must display Appropriate Legal Notices, as required under | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | * Section 5 of the GNU General Public License version 3. | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | 28 | + * |
| 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | * these Appropriate Legal Notices must retain the display of the "Powered by | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | 33 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 34 | * copyright notice. | 34 | * copyright notice. |
| 35 | * Contributor( s): ______________________________________ | 35 | * Contributor( s): ______________________________________ |
| 36 | * | 36 | * |
| @@ -61,6 +61,11 @@ function search_alias_compare($a, $b) | @@ -61,6 +61,11 @@ function search_alias_compare($a, $b) | ||
| 61 | return ($a['alias'] < $b['alias'])?-1:1; | 61 | return ($a['alias'] < $b['alias'])?-1:1; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | +function searchfix($str) | ||
| 65 | +{ | ||
| 66 | + return str_replace(array("\n","\r"), array('',''), addslashes($str)); | ||
| 67 | +} | ||
| 68 | + | ||
| 64 | class SearchHelper | 69 | class SearchHelper |
| 65 | { | 70 | { |
| 66 | public static function correctPath($path) | 71 | public static function correctPath($path) |
| @@ -109,7 +114,7 @@ class SearchHelper | @@ -109,7 +114,7 @@ class SearchHelper | ||
| 109 | { | 114 | { |
| 110 | if ($dt++ > 0) $documenttypes_str .= ','; | 115 | if ($dt++ > 0) $documenttypes_str .= ','; |
| 111 | $id=$user['id']; | 116 | $id=$user['id']; |
| 112 | - $name=(addslashes($user['name'])); | 117 | + $name=searchfix($user['name']); |
| 113 | 118 | ||
| 114 | $documenttypes_str .= "\n\t{id: \"$id\", name: \"$name\"}"; | 119 | $documenttypes_str .= "\n\t{id: \"$id\", name: \"$name\"}"; |
| 115 | } | 120 | } |
| @@ -152,7 +157,7 @@ class SearchHelper | @@ -152,7 +157,7 @@ class SearchHelper | ||
| 152 | { | 157 | { |
| 153 | if ($uo++ > 0) $users_str .= ','; | 158 | if ($uo++ > 0) $users_str .= ','; |
| 154 | $id=$user['id']; | 159 | $id=$user['id']; |
| 155 | - $name=(addslashes($user['name'])); | 160 | + $name=searchfix($user['name']); |
| 156 | 161 | ||
| 157 | $users_str .= "\n\t{id: \"$id\", name: \"$name\"}"; | 162 | $users_str .= "\n\t{id: \"$id\", name: \"$name\"}"; |
| 158 | } | 163 | } |
| @@ -172,8 +177,8 @@ class SearchHelper | @@ -172,8 +177,8 @@ class SearchHelper | ||
| 172 | foreach($fields as $field) | 177 | foreach($fields as $field) |
| 173 | { | 178 | { |
| 174 | if ($fo++ > 0) $fields_str .= ','; | 179 | if ($fo++ > 0) $fields_str .= ','; |
| 175 | - $alias = (addslashes($field['alias'])); | ||
| 176 | - $display = (addslashes($field['display'])); | 180 | + $alias = searchfix($field['alias']); |
| 181 | + $display = searchfix($field['display']); | ||
| 177 | $type = $field['type']; | 182 | $type = $field['type']; |
| 178 | $fields_str .= "\n\t{alias: \"$alias\", name: \"$display\", type:\"$type\"}"; | 183 | $fields_str .= "\n\t{alias: \"$alias\", name: \"$display\", type:\"$type\"}"; |
| 179 | } | 184 | } |
| @@ -195,7 +200,7 @@ class SearchHelper | @@ -195,7 +200,7 @@ class SearchHelper | ||
| 195 | { | 200 | { |
| 196 | if ($wo++ > 0) $workflow_str .= ','; | 201 | if ($wo++ > 0) $workflow_str .= ','; |
| 197 | $wid = $workflow['id']; | 202 | $wid = $workflow['id']; |
| 198 | - $name = (addslashes($workflow['name'])); | 203 | + $name = searchfix($workflow['name']); |
| 199 | 204 | ||
| 200 | $workflow_str .= "\n\t{id:\"$wid\", name: \"$name\", states: [ "; | 205 | $workflow_str .= "\n\t{id:\"$wid\", name: \"$name\", states: [ "; |
| 201 | 206 | ||
| @@ -207,7 +212,7 @@ class SearchHelper | @@ -207,7 +212,7 @@ class SearchHelper | ||
| 207 | { | 212 | { |
| 208 | if ($so++>0) $workflow_str .= ','; | 213 | if ($so++>0) $workflow_str .= ','; |
| 209 | $sid = $state['id']; | 214 | $sid = $state['id']; |
| 210 | - $name=(addslashes($state['name'])); | 215 | + $name=searchfix($state['name']); |
| 211 | $result['workflows'][$wid]['states'][$sid] = $state; | 216 | $result['workflows'][$wid]['states'][$sid] = $state; |
| 212 | $workflow_str .= "\n\t\t{id:\"$wid\", name: \"$name\"}"; | 217 | $workflow_str .= "\n\t\t{id:\"$wid\", name: \"$name\"}"; |
| 213 | } | 218 | } |
| @@ -230,8 +235,8 @@ class SearchHelper | @@ -230,8 +235,8 @@ class SearchHelper | ||
| 230 | foreach($fieldsets as $fieldset) | 235 | foreach($fieldsets as $fieldset) |
| 231 | { | 236 | { |
| 232 | $fsid=$fieldset['id']; | 237 | $fsid=$fieldset['id']; |
| 233 | - $name = (addslashes($fieldset['name'])); | ||
| 234 | - $desc = (addslashes($fieldset['description'])); | 238 | + $name = searchfix($fieldset['name']); |
| 239 | + $desc = searchfix($fieldset['description']); | ||
| 235 | if ($fso++>0) $fieldset_str .= ','; | 240 | if ($fso++>0) $fieldset_str .= ','; |
| 236 | $fieldset_str .= "\n\t{id:\"$fsid\",name:\"$name\",description:\"$desc\", fields: ["; | 241 | $fieldset_str .= "\n\t{id:\"$fsid\",name:\"$name\",description:\"$desc\", fields: ["; |
| 237 | 242 | ||
| @@ -244,8 +249,8 @@ class SearchHelper | @@ -244,8 +249,8 @@ class SearchHelper | ||
| 244 | { | 249 | { |
| 245 | if ($fo++ >0) $fieldset_str .= ','; | 250 | if ($fo++ >0) $fieldset_str .= ','; |
| 246 | $fid = $field['id']; | 251 | $fid = $field['id']; |
| 247 | - $name= (addslashes($field['name'])); | ||
| 248 | - $desc = (addslashes($field['description'])); | 252 | + $name= searchfix($field['name']); |
| 253 | + $desc = searchfix($field['description']); | ||
| 249 | $datatype=$field['datatype']; | 254 | $datatype=$field['datatype']; |
| 250 | $control=$field['control']; | 255 | $control=$field['control']; |
| 251 | $fieldset_str .= "\n\t\t{id:\"$fid\", name:\"$name\", description:\"$desc\", datatype:\"$datatype\", control:\"$control\", options: ["; | 256 | $fieldset_str .= "\n\t\t{id:\"$fid\", name:\"$name\", description:\"$desc\", datatype:\"$datatype\", control:\"$control\", options: ["; |
| @@ -259,7 +264,7 @@ class SearchHelper | @@ -259,7 +264,7 @@ class SearchHelper | ||
| 259 | { | 264 | { |
| 260 | if ($oo++ > 0) $fieldset_str .= ','; | 265 | if ($oo++ > 0) $fieldset_str .= ','; |
| 261 | $oid = $option['id']; | 266 | $oid = $option['id']; |
| 262 | - $name= (addslashes($option['name'])); | 267 | + $name= searchfix($option['name']); |
| 263 | $fieldset_str .= "\n\t\t\t{id: \"$oid\", name: \"$name\"}"; | 268 | $fieldset_str .= "\n\t\t\t{id: \"$oid\", name: \"$name\"}"; |
| 264 | } | 269 | } |
| 265 | $fieldset_str .= ']}'; | 270 | $fieldset_str .= ']}'; |