|
From: <dgl...@us...> - 2003-08-18 00:27:17
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv16859/modules/core/src/com/babeldoc/core/pipeline/stage
Modified Files:
JournalUpdatePipelineStage.java
Log Message:
Protect journal integrity by converting harmful characters into html equivalents
Index: JournalUpdatePipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/JournalUpdatePipelineStage.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** JournalUpdatePipelineStage.java 17 Aug 2003 22:40:45 -0000 1.2
--- JournalUpdatePipelineStage.java 18 Aug 2003 00:23:21 -0000 1.3
***************
*** 126,133 ****
}
! // Add a journal entry for the nessage
try {
((SimpleJournal)getJournal()).logMessage(getTicket(), getPipelineName() + "." + getName(),
! getOptions(JOURNAL_MESSAGE));
}
catch (JournalException e) {
--- 126,139 ----
}
! // get the message to be added
! String message = getOptions(JOURNAL_MESSAGE);
!
! // translate message, converting any problem characters into their html equivalent
! message = translateMessage(message);
!
! // add a journal entry for the message
try {
((SimpleJournal)getJournal()).logMessage(getTicket(), getPipelineName() + "." + getName(),
! message);
}
catch (JournalException e) {
***************
*** 137,139 ****
--- 143,169 ----
return super.processHelper();
}
+
+ /**
+ * Translates the message into a 'journal-safe' message, converting any
+ * problem characters into HTML equivalents
+ */
+ public String translateMessage(String message) {
+ StringBuffer sb = new StringBuffer();
+ for (int i=0; i<message.length(); i++) {
+ if (message.charAt(i) == '\n') {
+ sb.append("<BR>");
+ }
+ else if (message.charAt(i) == ',') {
+ sb.append(",");
+ }
+ else if (message.charAt(i) == '"') {
+ sb.append(""");
+ }
+ else {
+ sb.append(message.charAt(i));
+ }
+ }
+ return new String(sb);
+ }
+
}
|