Commit b526703e277e47698f0d0a49a59e7284e61bc959

Authored by Conrad Vermeulen
1 parent 0c5b814f

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/trunk@9201 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 6 * Document Management Made Simple
7 7 * Copyright (C) 2008 KnowledgeTree Inc.
8 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  9 + *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
12 12 * Free Software Foundation.
13   - *
  13 + *
14 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 17 * details.
18   - *
  18 + *
19 19 * You should have received a copy of the GNU General Public License
20 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 23 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  24 + *
25 25 * The interactive user interfaces in modified source and object code versions
26 26 * of this program must display Appropriate Legal Notices, as required under
27 27 * Section 5 of the GNU General Public License version 3.
28   - *
  28 + *
29 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 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 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 34 * copyright notice.
35 35 * Contributor( s): ______________________________________
36 36 *
... ... @@ -61,6 +61,11 @@ function search_alias_compare($a, $b)
61 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 69 class SearchHelper
65 70 {
66 71 public static function correctPath($path)
... ... @@ -109,7 +114,7 @@ class SearchHelper
109 114 {
110 115 if ($dt++ > 0) $documenttypes_str .= ',';
111 116 $id=$user['id'];
112   - $name=(addslashes($user['name']));
  117 + $name=searchfix($user['name']);
113 118  
114 119 $documenttypes_str .= "\n\t{id: \"$id\", name: \"$name\"}";
115 120 }
... ... @@ -152,7 +157,7 @@ class SearchHelper
152 157 {
153 158 if ($uo++ > 0) $users_str .= ',';
154 159 $id=$user['id'];
155   - $name=(addslashes($user['name']));
  160 + $name=searchfix($user['name']);
156 161  
157 162 $users_str .= "\n\t{id: \"$id\", name: \"$name\"}";
158 163 }
... ... @@ -172,8 +177,8 @@ class SearchHelper
172 177 foreach($fields as $field)
173 178 {
174 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 182 $type = $field['type'];
178 183 $fields_str .= "\n\t{alias: \"$alias\", name: \"$display\", type:\"$type\"}";
179 184 }
... ... @@ -195,7 +200,7 @@ class SearchHelper
195 200 {
196 201 if ($wo++ > 0) $workflow_str .= ',';
197 202 $wid = $workflow['id'];
198   - $name = (addslashes($workflow['name']));
  203 + $name = searchfix($workflow['name']);
199 204  
200 205 $workflow_str .= "\n\t{id:\"$wid\", name: \"$name\", states: [ ";
201 206  
... ... @@ -207,7 +212,7 @@ class SearchHelper
207 212 {
208 213 if ($so++>0) $workflow_str .= ',';
209 214 $sid = $state['id'];
210   - $name=(addslashes($state['name']));
  215 + $name=searchfix($state['name']);
211 216 $result['workflows'][$wid]['states'][$sid] = $state;
212 217 $workflow_str .= "\n\t\t{id:\"$wid\", name: \"$name\"}";
213 218 }
... ... @@ -230,8 +235,8 @@ class SearchHelper
230 235 foreach($fieldsets as $fieldset)
231 236 {
232 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 240 if ($fso++>0) $fieldset_str .= ',';
236 241 $fieldset_str .= "\n\t{id:\"$fsid\",name:\"$name\",description:\"$desc\", fields: [";
237 242  
... ... @@ -244,8 +249,8 @@ class SearchHelper
244 249 {
245 250 if ($fo++ >0) $fieldset_str .= ',';
246 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 254 $datatype=$field['datatype'];
250 255 $control=$field['control'];
251 256 $fieldset_str .= "\n\t\t{id:\"$fid\", name:\"$name\", description:\"$desc\", datatype:\"$datatype\", control:\"$control\", options: [";
... ... @@ -259,7 +264,7 @@ class SearchHelper
259 264 {
260 265 if ($oo++ > 0) $fieldset_str .= ',';
261 266 $oid = $option['id'];
262   - $name= (addslashes($option['name']));
  267 + $name= searchfix($option['name']);
263 268 $fieldset_str .= "\n\t\t\t{id: \"$oid\", name: \"$name\"}";
264 269 }
265 270 $fieldset_str .= ']}';
... ...