mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AppCode:Scheme: properly escape xml text and attributes (OC-3323)
This commit is contained in:
@@ -514,7 +514,7 @@ public class JDOMUtil {
|
||||
* Returns null if no escapement necessary.
|
||||
*/
|
||||
@Nullable
|
||||
private static String escapeChar(char c, boolean escapeSpaces, boolean escapeLineEnds) {
|
||||
private static String escapeChar(char c, boolean escapeApostrophes, boolean escapeSpaces, boolean escapeLineEnds) {
|
||||
switch (c) {
|
||||
case '\n': return escapeLineEnds ? " " : null;
|
||||
case '\r': return escapeLineEnds ? " " : null;
|
||||
@@ -523,6 +523,7 @@ public class JDOMUtil {
|
||||
case '<': return "<";
|
||||
case '>': return ">";
|
||||
case '\"': return """;
|
||||
case '\'': return escapeApostrophes ? "'": null;
|
||||
case '&': return "&";
|
||||
}
|
||||
return null;
|
||||
@@ -535,10 +536,15 @@ public class JDOMUtil {
|
||||
|
||||
@NotNull
|
||||
public static String escapeText(String text, boolean escapeSpaces, boolean escapeLineEnds) {
|
||||
return escapeText(text, false, escapeSpaces, escapeLineEnds);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String escapeText(String text, boolean escapeApostrophes, boolean escapeSpaces, boolean escapeLineEnds) {
|
||||
StringBuffer buffer = null;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
final char ch = text.charAt(i);
|
||||
final String quotation = escapeChar(ch, escapeSpaces, escapeLineEnds);
|
||||
final String quotation = escapeChar(ch, escapeApostrophes, escapeSpaces, escapeLineEnds);
|
||||
|
||||
if (buffer == null) {
|
||||
if (quotation != null) {
|
||||
|
||||
Reference in New Issue
Block a user