Browse Source

Escape special characters

Neal Wilson 6 years ago
parent
commit
0add093edf
Signed by: Neal Wilson <neal@typica.us> GPG Key ID: 2A0BDDE701E66EB9
1 changed files with 19 additions and 19 deletions
  1. 19
    19
      config/Reports/auco.xml

+ 19
- 19
config/Reports/auco.xml View File

151
                     output.writeAttribute("href", "typica://script/r" + rowIndex);
151
                     output.writeAttribute("href", "typica://script/r" + rowIndex);
152
                     rowIndex++;
152
                     rowIndex++;
153
                     rowData.push(query.value(0));
153
                     rowData.push(query.value(0));
154
-                    output.writeCharacters(query.value(0));
154
+                    output.writeCharacters(sanitize(query.value(0)));
155
                     output.writeEndElement();
155
                     output.writeEndElement();
156
                     output.writeEndElement();
156
                     output.writeEndElement();
157
-                    output.writeTextElement("td", query.value(1));
158
-                    output.writeTextElement("td", query.value(2));
159
-                    output.writeTextElement("td", query.value(3));
160
-                    output.writeTextElement("td", query.value(4));
161
-                    output.writeTextElement("td", query.value(5));
162
-                    output.writeTextElement("td", query.value(6));
163
-                    output.writeTextElement("td", query.value(7));
164
-                    output.writeTextElement("td", query.value(8));
157
+                    for(var i = 1; i < 9; i++) {
158
+                        output.writeTextElement("td", query.value(i));
159
+                    }
165
                     output.writeEndElement();
160
                     output.writeEndElement();
166
                 }
161
                 }
167
                 output.writeStartElement("tr");
162
                 output.writeStartElement("tr");
187
                     output.writeAttribute("href", "typica://script/d" + rowIndex);
182
                     output.writeAttribute("href", "typica://script/d" + rowIndex);
188
                     rowIndex++;
183
                     rowIndex++;
189
                     rowData.push(query.value(0));
184
                     rowData.push(query.value(0));
190
-                    output.writeCharacters(query.value(0));
185
+                    output.writeCharacters(sanitize(query.value(0)));
191
                     output.writeEndElement();
186
                     output.writeEndElement();
192
                     output.writeEndElement();
187
                     output.writeEndElement();
193
-                    output.writeTextElement("td", query.value(1));
194
-                    output.writeTextElement("td", query.value(2));
195
-                    output.writeTextElement("td", query.value(3));
196
-                    output.writeTextElement("td", query.value(4));
197
-                    output.writeTextElement("td", query.value(5));
198
-                    output.writeTextElement("td", query.value(6));
199
-                    output.writeTextElement("td", query.value(7));
200
-                    output.writeTextElement("td", query.value(8));
188
+                    for(var i = 1; i < 9; i++) {
189
+                        output.writeTextElement("td", query.value(i));
190
+                    }
201
                     output.writeEndElement();
191
                     output.writeEndElement();
202
                 }
192
                 }
203
                 query = query.invalidate();
193
                 query = query.invalidate();
264
                     details += "<tr>";
254
                     details += "<tr>";
265
                     details += '<td><a href="typica://script/i' + query.value(0) + '">' + query.value(0) + "</a></td>";
255
                     details += '<td><a href="typica://script/i' + query.value(0) + '">' + query.value(0) + "</a></td>";
266
                     for(var i = 1; i < 7; i++) {
256
                     for(var i = 1; i < 7; i++) {
267
-                        details += "<td>" + query.value(i) + "</td>";
257
+                        details += "<td>" + sanitize(query.value(i)) + "</td>";
268
                     }
258
                     }
269
                     details += "</tr>";
259
                     details += "</tr>";
270
                 }
260
                 }
272
                 details += "</table></td></tr>";
262
                 details += "</table></td></tr>";
273
                 element.appendOutside(details);
263
                 element.appendOutside(details);
274
             });
264
             });
265
+            function sanitize(value) {
266
+                var replacement_chars = {
267
+                    "&": "&amp;",
268
+                    "<": "&lt;",
269
+                    ">": "&gt;",
270
+                    "\"": "&quot;",
271
+                    "'": "&#39;"
272
+                };
273
+                return value.replace(/[&<>"']/g, function(m) { return replacement_chars[m]; });
274
+            }
275
         ]]>
275
         ]]>
276
     </program>
276
     </program>
277
 </window>
277
 </window>

Loading…
Cancel
Save