|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2008 the original author or authors. |
| 2 | + * Copyright 2002-2013 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
21 | 21 | * Escapes based on the JavaScript 1.5 recommendation.
|
22 | 22 | *
|
23 | 23 | * <p>Reference:
|
24 |
| - * <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Literals#String_Literals"> |
25 |
| - * Core JavaScript 1.5 Guide |
26 |
| - * </a> |
| 24 | + * <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Values,_variables,_and_literals#String_literals"> |
| 25 | + * JavaScript Guide</a> on Mozilla Developer Network. |
27 | 26 | *
|
28 | 27 | * @author Juergen Hoeller
|
29 | 28 | * @author Rob Harrop
|
| 29 | + * @author Rossen Stoyanchev |
30 | 30 | * @since 1.1.1
|
31 | 31 | */
|
32 | 32 | public class JavaScriptUtils {
|
33 | 33 |
|
34 | 34 | /**
|
35 |
| - * Turn special characters into escaped characters conforming to JavaScript. |
36 |
| - * Handles complete character set defined in HTML 4.01 recommendation. |
| 35 | + * Turn JavaScript special characters into escaped characters. |
| 36 | + * |
37 | 37 | * @param input the input string
|
38 |
| - * @return the escaped string |
| 38 | + * @return the string with escaped characters |
39 | 39 | */
|
40 | 40 | public static String javaScriptEscape(String input) {
|
41 | 41 | if (input == null) {
|
@@ -73,6 +73,13 @@ else if (c == '\r') {
|
73 | 73 | else if (c == '\f') {
|
74 | 74 | filtered.append("\\f");
|
75 | 75 | }
|
| 76 | + else if (c == '\b') { |
| 77 | + filtered.append("\\b"); |
| 78 | + } |
| 79 | + // No '\v' in Java, use octal value for VT ascii char |
| 80 | + else if (c == '\013') { |
| 81 | + filtered.append("\\v"); |
| 82 | + } |
76 | 83 | else {
|
77 | 84 | filtered.append(c);
|
78 | 85 | }
|
|
0 commit comments