소스 검색

Ticket summaries are now html-encoded (#14579)

Change-Id: Ia6a4342f6488da27310afe14421ef5af68e436bc
tags/7.4.0.beta1
Sara Seppola 9 년 전
부모
커밋
e84bdc22b1
1개의 변경된 파일49개의 추가작업 그리고 6개의 파일을 삭제
  1. 49
    6
      buildhelpers/src/com/vaadin/buildhelpers/FetchReleaseNotesTickets.java

+ 49
- 6
buildhelpers/src/com/vaadin/buildhelpers/FetchReleaseNotesTickets.java 파일 보기

@@ -99,12 +99,9 @@ public class FetchReleaseNotesTickets {
continue;
}
String summary = fields[1];
if (summary.startsWith("\"") && summary.endsWith("\"")) {
// If a summary starts with " and ends with " then all quotes in
// the summary are encoded as double quotes
summary = summary.substring(1, summary.length() - 1);
summary = summary.replace("\"\"", "\"");
}

summary = modifySummaryString(summary);

String badge = "<td></td>";
if (fields.length >= 8 && !fields[7].equals("")) {
badge = "<td class=\"bfp\"><span class=\"bfp\">Priority</span></td>";
@@ -119,6 +116,52 @@ public class FetchReleaseNotesTickets {
urlStream.close();
}

private static String modifySummaryString(String summary) {

if (summary.startsWith("\"") && summary.endsWith("\"")) {
// If a summary starts with " and ends with " then all quotes in
// the summary are encoded as double quotes
summary = summary.substring(1, summary.length() - 1);
summary = summary.replace("\"\"", "\"");
}

// this is needed for escaping html
summary = escapeHtml(summary);

return summary;
}

/**
* @since
* @param string
* the string to be html-escaped
* @return string in html-escape format
*/
private static String escapeHtml(String string) {

StringBuffer buf = new StringBuffer(string.length() * 2);

// we check the string character by character and escape only special
// characters
for (int i = 0; i < string.length(); ++i) {

char ch = string.charAt(i);
String charString = ch + "";

if ((charString).matches("[a-zA-Z0-9., ]")) {
// character is letter, digit, dot, comma or whitespace
buf.append(ch);
} else {
int charInt = ch;
buf.append("&");
buf.append("#");
buf.append(charInt);
buf.append(";");
}
}
return buf.toString();
}

private static void usage() {
System.err.println("Usage: "
+ FetchReleaseNotesTickets.class.getSimpleName()

Loading…
취소
저장