Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SerializationUtils |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.common.ui.server.serialization; | |
17 | ||
18 | /** | |
19 | * This is a description of what this class does - hjohnson don't forget to fill this in. | |
20 | * | |
21 | * @author Kuali Student Team (kuali-student@googlegroups.com) | |
22 | * | |
23 | */ | |
24 | 0 | public class SerializationUtils { |
25 | // Server Side String utils | |
26 | public static String escapeForSingleQuotedJavaScriptString( String s ) | |
27 | { | |
28 | 0 | s = escapeScriptTags( s ); // <script> -> <xxxscript> |
29 | 0 | s = escapeBackslash( s ); |
30 | 0 | s = escapeSingleQuotes( s ); |
31 | 0 | return s; |
32 | } | |
33 | public static String escapeScriptTags( String s ) | |
34 | { | |
35 | 0 | return s |
36 | .replaceAll("(?si)<\\s*script.*?>", "<xxxscript>") | |
37 | .replaceAll("(?si)</\\s*script\\s*>", "</xxxscript>"); | |
38 | } | |
39 | public static String escapeBackslash( String s ) | |
40 | { | |
41 | 0 | return s.replaceAll("\\\\","\\\\\\\\" ); |
42 | } | |
43 | public static String escapeSingleQuotes( String s ) { | |
44 | 0 | return s.replaceAll("'","\\\\'" ); |
45 | } | |
46 | ||
47 | } |