$log_part .= " task_id=\"".$this->taskMap[$record['task_id']]."\"";
$log_part .= " timesheet_id=\"".$this->timesheetMap[$record['timesheet_id']]."\"";
$log_part .= " invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\"";
- $log_part .= " comment=\"".htmlspecialchars($record['comment'])."\"";
+ $log_part .= " comment=\"".$this->encodeLineBreaks($record['comment'])."\"";
$log_part .= " billable=\"".$record['billable']."\"";
$log_part .= " approved=\"".$record['approved']."\"";
$log_part .= " paid=\"".$record['paid']."\"";
$expense_item_part .= " user_id=\"".$this->userMap[$expense_item['user_id']]."\"";
$expense_item_part .= " client_id=\"".$this->clientMap[$expense_item['client_id']]."\"";
$expense_item_part .= " project_id=\"".$this->projectMap[$expense_item['project_id']]."\"";
- $expense_item_part .= " name=\"".htmlspecialchars($expense_item['name'])."\"";
+ $expense_item_part .= " name=\"".$this->encodeLineBreaks($expense_item['name'])."\"";
$expense_item_part .= " cost=\"".$expense_item['cost']."\"";
$expense_item_part .= " invoice_id=\"".$this->invoiceMap[$expense_item['invoice_id']]."\"";
$expense_item_part .= " approved=\"".$expense_item['approved']."\"";
foreach ($templates as $template) {
$template_part = $this->indentation.' '."<template name=\"".htmlspecialchars($template['name'])."\"";
$template_part .= " description=\"".htmlspecialchars($template['description'])."\"";
- $template_part .= " content=\"".htmlspecialchars($template['content'])."\"";
+ $template_part .= " content=\"".$this->encodeLineBreaks($template['content'])."\"";
$template_part .= " status=\"".$template['status']."\"";
$template_part .= "></template>\n";
fwrite($this->file, $template_part);
fwrite($this->file, $this->indentation."</group>\n");
}
+
+ // encodeLineBreaks encodes line breaks with an escape sequence.
+ // We do this, because our strings are attribute values inside XML tags.
+ //
+ // If we don't, we lose line breaks after importing data because
+ // XML parser converts line breaks into a single white character.
+ //
+ // TODO: investigate whether we need to encode \t, etc.
+ private function encodeLineBreaks($source) {
+ $result = htmlspecialchars($source);
+ $result = str_replace ("\n", ' ', $result);
+ $result = str_replace ("\r", ' ', $result);
+ return $result;
+ }
}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.56.4855 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.57.4856 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>