ASF Bugzilla – Attachment 29376 Details for
Bug 53867
Performance tuning solution for PageContextImpl.XmlEscape
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for PageContextImpl.java
PageContextImpl.diff (text/plain), 2.21 KB, created by
Sheldon Shao
on 2012-09-13 14:06:21 UTC
(
hide
)
Description:
Patch for PageContextImpl.java
Filename:
MIME Type:
Creator:
Sheldon Shao
Created:
2012-09-13 14:06:21 UTC
Size:
2.21 KB
patch
obsolete
>Index: runtime/PageContextImpl.java >=================================================================== >--- runtime/PageContextImpl.java (revision 1384312) >+++ runtime/PageContextImpl.java (working copy) >@@ -913,28 +913,69 @@ > } > } > >- private static String XmlEscape(String s) { >- if (s == null) >+ protected static String XmlEscape(String s) { >+ if (s == null) { > return null; >- StringBuilder sb = new StringBuilder(); >- for (int i = 0; i < s.length(); i++) { >+ } >+ int len = s.length(); >+ >+ /* >+ * Look for any "bad" characters, Escape "bad" character was found >+ */ >+ // ASCII " 34 & 38 ' 39 < 60 > 62 >+ for (int i = 0; i < len; i++) { > char c = s.charAt(i); >+ if (c >= '\"' >+ && c <= '>' >+ && (c == '<' || c == '>' || c == '\'' || c == '&' || c == '"')) { >+ // need to escape them and then quote the whole string >+ StringBuilder sb = new StringBuilder((int) (len * 1.2)); >+ sb.append(s, 0, i); >+ int pos = i + 1; >+ for (int j = i; j < len; j++) { >+ c = s.charAt(j); >+ if (c >= '\"' && c <= '>') { > if (c == '<') { >+ if (j > pos) { >+ sb.append(s, pos, j); >+ } > sb.append("<"); >+ pos = j + 1; > } else if (c == '>') { >+ if (j > pos) { >+ sb.append(s, pos, j); >+ } > sb.append(">"); >+ pos = j + 1; > } else if (c == '\'') { >+ if (j > pos) { >+ sb.append(s, pos, j); >+ } > sb.append("'"); // ' >+ pos = j + 1; > } else if (c == '&') { >+ if (j > pos) { >+ sb.append(s, pos, j); >+ } > sb.append("&"); >+ pos = j + 1; > } else if (c == '"') { >+ if (j > pos) { >+ sb.append(s, pos, j); >+ } > sb.append("""); // " >- } else { >- sb.append(c); >+ pos = j + 1; > } > } >+ } >+ if (pos < len) { >+ sb.append(s, pos, len); >+ } > return sb.toString(); > } >+ } >+ return s; >+ } > > /** > * Proprietary method to evaluate EL expressions. XXX - This method should
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 53867
:
29369
|
29370
| 29376