mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-12 19:33:03 +00:00
Implemented 'allowed encoding' option
SVN revision: 1719
This commit is contained in:
parent
2dd78c6c10
commit
be46cb4082
@ -2152,6 +2152,25 @@ Options Location = Main Building{a}, New Building{b}, Old Building{c}
|
|||||||
"http://midas.psi.ch/elog/elcode_en.html">ELCode</a> encoding, to
|
"http://midas.psi.ch/elog/elcode_en.html">ELCode</a> encoding, to
|
||||||
<b>2</b> for HTML encoding. The default is <b>0</b>.
|
<b>2</b> for HTML encoding. The default is <b>0</b>.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b><code>Allowed encoding = <n></code></b><br>
|
||||||
|
Allowed encoding options. <b><code><n></b></code> can be the sum of
|
||||||
|
following flags:
|
||||||
|
<ul>
|
||||||
|
<li>1 : Plain
|
||||||
|
</li>
|
||||||
|
<li>2 : ELCode encoding
|
||||||
|
</li>
|
||||||
|
<li>4 : HTML encoding
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
To allow plain and HTML encoding for example, set
|
||||||
|
<b><code><n></b></code> to 5. Default is <b>3</b>. Note that
|
||||||
|
allowing HTML encoding may cause some security risk, since an elog
|
||||||
|
entry may contain malicious scripting code. It should therefor only
|
||||||
|
be allowed for installations where it is really needed and with not
|
||||||
|
public write access.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b><code>Suppress default = 0|1|2|3</code></b><br>
|
<b><code>Suppress default = 0|1|2|3</code></b><br>
|
||||||
This specifies the default state of the "<i>Suppress Email
|
This specifies the default state of the "<i>Suppress Email
|
||||||
|
|||||||
94
src/elogd.c
94
src/elogd.c
@ -8444,7 +8444,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
|||||||
{
|
{
|
||||||
int i, j, n, index, aindex, size, width, height, fh, length, input_size, input_maxlen,
|
int i, j, n, index, aindex, size, width, height, fh, length, input_size, input_maxlen,
|
||||||
format_flags[MAX_N_ATTR], year, month, day, hour, min, sec, n_attr, n_disp_attr, n_lines,
|
format_flags[MAX_N_ATTR], year, month, day, hour, min, sec, n_attr, n_disp_attr, n_lines,
|
||||||
attr_index[MAX_N_ATTR], enc_selected, show_smileys, show_text, n_moptions, display_inline;
|
attr_index[MAX_N_ATTR], enc_selected, show_smileys, show_text, n_moptions, display_inline,
|
||||||
|
allowed_encoding;
|
||||||
char str[2 * NAME_LENGTH], preset[2 * NAME_LENGTH], *p, *pend, star[80], comment[10000], reply_string[256],
|
char str[2 * NAME_LENGTH], preset[2 * NAME_LENGTH], *p, *pend, star[80], comment[10000], reply_string[256],
|
||||||
list[MAX_N_ATTR][NAME_LENGTH], file_name[256], *buffer, format[256], date[80], script[256],
|
list[MAX_N_ATTR][NAME_LENGTH], file_name[256], *buffer, format[256], date[80], script[256],
|
||||||
attrib[MAX_N_ATTR][NAME_LENGTH], *text, orig_tag[80], reply_tag[MAX_REPLY_TO * 10],
|
attrib[MAX_N_ATTR][NAME_LENGTH], *text, orig_tag[80], reply_tag[MAX_REPLY_TO * 10],
|
||||||
@ -9965,29 +9966,56 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
|||||||
|
|
||||||
/* Encoding radio buttons */
|
/* Encoding radio buttons */
|
||||||
|
|
||||||
rsprintf("<b>%s</b>: ", loc("Encoding"));
|
if (getcfg(lbs->name, "Allowed encoding", str, sizeof(str)))
|
||||||
|
allowed_encoding = atoi(str);
|
||||||
if (enc_selected == 0)
|
|
||||||
rsprintf("<input type=radio id=\"ELCode\" name=\"encoding\" value=\"ELCode\" checked>");
|
|
||||||
else
|
else
|
||||||
rsprintf
|
allowed_encoding = 3;
|
||||||
("<input type=radio id=\"ELCode\" name=\"encoding\" value=\"ELCode\" onclick=\"cond_submit()\">");
|
|
||||||
rsprintf
|
|
||||||
("<label for=\"ELCode\"><a target=\"_blank\" href=\"?cmd=HelpELCode\">ELCode</a> </label>\n");
|
|
||||||
|
|
||||||
if (enc_selected == 1)
|
if (allowed_encoding < 1 || allowed_encoding > 7) {
|
||||||
rsprintf("<input type=radio id=\"plain\" name=\"encoding\" value=\"plain\" checked>");
|
rsprintf("<h1>Invalid \"Allowed encoding\" in configuration file, value must be between 1 and 7</h1>\n");
|
||||||
else
|
rsprintf("</table><!-- show_standard_title -->\n");
|
||||||
rsprintf
|
show_bottom_text(lbs);
|
||||||
("<input type=radio id=\"plain\" name=\"encoding\" value=\"plain\" onclick=\"cond_submit()\">");
|
rsprintf("</form></body></html>\r\n");
|
||||||
rsprintf("<label for=\"plain\">plain </label>\n");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (enc_selected == 2)
|
if (allowed_encoding == 1)
|
||||||
rsprintf("<input type=radio id=\"HTML\" name=\"encoding\" value=\"HTML\" checked>");
|
rsprintf("<input type=\"hidden\" name=\"encoding\" value=\"plain\">\n");
|
||||||
else
|
else if (allowed_encoding == 2)
|
||||||
rsprintf
|
rsprintf("<input type=\"hidden\" name=\"encoding\" value=\"ELCode\">\n");
|
||||||
("<input type=radio id=\"HTML\" name=\"encoding\" value=\"HTML\" onclick=\"cond_submit()\">");
|
else if (allowed_encoding == 4)
|
||||||
rsprintf("<label for=\"HTML\">HTML </label>\n");
|
rsprintf("<input type=\"hidden\" name=\"encoding\" value=\"HTML\">\n");
|
||||||
|
else {
|
||||||
|
rsprintf("<b>%s</b>: ", loc("Encoding"));
|
||||||
|
|
||||||
|
if (allowed_encoding & 2) {
|
||||||
|
if (enc_selected == 0)
|
||||||
|
rsprintf("<input type=radio id=\"ELCode\" name=\"encoding\" value=\"ELCode\" checked>");
|
||||||
|
else
|
||||||
|
rsprintf
|
||||||
|
("<input type=radio id=\"ELCode\" name=\"encoding\" value=\"ELCode\" onclick=\"cond_submit()\">");
|
||||||
|
rsprintf
|
||||||
|
("<label for=\"ELCode\"><a target=\"_blank\" href=\"?cmd=HelpELCode\">ELCode</a> </label>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowed_encoding & 1) {
|
||||||
|
if (enc_selected == 1)
|
||||||
|
rsprintf("<input type=radio id=\"plain\" name=\"encoding\" value=\"plain\" checked>");
|
||||||
|
else
|
||||||
|
rsprintf
|
||||||
|
("<input type=radio id=\"plain\" name=\"encoding\" value=\"plain\" onclick=\"cond_submit()\">");
|
||||||
|
rsprintf("<label for=\"plain\">plain </label>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowed_encoding & 4) {
|
||||||
|
if (enc_selected == 2)
|
||||||
|
rsprintf("<input type=radio id=\"HTML\" name=\"encoding\" value=\"HTML\" checked>");
|
||||||
|
else
|
||||||
|
rsprintf
|
||||||
|
("<input type=radio id=\"HTML\" name=\"encoding\" value=\"HTML\" onclick=\"cond_submit()\">");
|
||||||
|
rsprintf("<label for=\"HTML\">HTML </label>\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rsprintf("<br>\n");
|
rsprintf("<br>\n");
|
||||||
}
|
}
|
||||||
@ -19155,7 +19183,8 @@ void submit_elog(LOGBOOK * lbs)
|
|||||||
mail_param[1000], *mail_to, *rcpt_to, full_name[256], att_file[MAX_ATTACHMENTS][256],
|
mail_param[1000], *mail_to, *rcpt_to, full_name[256], att_file[MAX_ATTACHMENTS][256],
|
||||||
slist[MAX_N_ATTR + 10][NAME_LENGTH], svalue[MAX_N_ATTR + 10][NAME_LENGTH], ua[NAME_LENGTH];
|
slist[MAX_N_ATTR + 10][NAME_LENGTH], svalue[MAX_N_ATTR + 10][NAME_LENGTH], ua[NAME_LENGTH];
|
||||||
int i, j, n, missing, first, index, mindex, suppress, message_id, resubmit_orig,
|
int i, j, n, missing, first, index, mindex, suppress, message_id, resubmit_orig,
|
||||||
mail_to_size, rcpt_to_size, ltime, year, month, day, hour, min, sec, n_attr, email_notify[1000];
|
mail_to_size, rcpt_to_size, ltime, year, month, day, hour, min, sec, n_attr, email_notify[1000],
|
||||||
|
allowed_encoding;
|
||||||
BOOL bedit;
|
BOOL bedit;
|
||||||
struct tm tms;
|
struct tm tms;
|
||||||
|
|
||||||
@ -19316,6 +19345,27 @@ void submit_elog(LOGBOOK * lbs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if allowed encoding */
|
||||||
|
if (getcfg(lbs->name, "Allowed encoding", str, sizeof(str)))
|
||||||
|
allowed_encoding = atoi(str);
|
||||||
|
else
|
||||||
|
allowed_encoding = 3;
|
||||||
|
|
||||||
|
strcpy(str, isparam("encoding") ? getparam("encoding") : "plain");
|
||||||
|
|
||||||
|
if (strieq(str, "plain") && (allowed_encoding & 1) == 0) {
|
||||||
|
show_error("Plain encoding not allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (strieq(str, "ELCode") && (allowed_encoding & 2) == 0) {
|
||||||
|
show_error("ELCode encoding not allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (strieq(str, "HTML") && (allowed_encoding & 4) == 0) {
|
||||||
|
show_error("HTML encoding not allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* get attachments */
|
/* get attachments */
|
||||||
for (i = 0; i < MAX_ATTACHMENTS; i++) {
|
for (i = 0; i < MAX_ATTACHMENTS; i++) {
|
||||||
sprintf(str, "attachment%d", i);
|
sprintf(str, "attachment%d", i);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user