Remove public HTML escaping declarations from log module.

This commit is contained in:
Sönke Ludwig 2016-11-02 20:24:41 +01:00
parent d06ad74ee3
commit 2071f30a1c

View file

@ -520,72 +520,22 @@ final class HTMLLogger : Logger {
</html>`); </html>`);
m_logFile.flush(); m_logFile.flush();
} }
}
private static void filterHTMLEscape(R, S)(ref R dst, S str)
/** Helper stuff. {
*/ for (;!str.empty;str.popFront()) {
/** Writes the HTML escaped version of a given string to an output range. auto ch = str.front;
*/ switch (ch) {
void filterHTMLEscape(R, S)(ref R dst, S str, HTMLEscapeFlags flags = HTMLEscapeFlags.escapeNewline) default: dst.put(ch); break;
if (isOutputRange!(R, dchar) && isInputRange!S) case '<': dst.put("&lt;"); break;
{ case '>': dst.put("&gt;"); break;
for (;!str.empty;str.popFront()) case '&': dst.put("&amp;"); break;
filterHTMLEscape(dst, str.front, flags); }
} }
/**
Writes the HTML escaped version of a character to an output range.
*/
void filterHTMLEscape(R)(ref R dst, dchar ch, HTMLEscapeFlags flags = HTMLEscapeFlags.escapeNewline )
{
switch (ch) {
default:
if (flags & HTMLEscapeFlags.escapeUnknown) {
dst.put("&#");
dst.put(to!string(cast(uint)ch));
dst.put(';');
} else dst.put(ch);
break;
case '"':
if (flags & HTMLEscapeFlags.escapeQuotes) dst.put("&quot;");
else dst.put('"');
break;
case '\'':
if (flags & HTMLEscapeFlags.escapeQuotes) dst.put("&#39;");
else dst.put('\'');
break;
case '\r', '\n':
if (flags & HTMLEscapeFlags.escapeNewline) {
dst.put("&#");
dst.put(to!string(cast(uint)ch));
dst.put(';');
} else dst.put(ch);
break;
case 'a': .. case 'z': goto case;
case 'A': .. case 'Z': goto case;
case '0': .. case '9': goto case;
case ' ', '\t', '-', '_', '.', ':', ',', ';',
'#', '+', '*', '?', '=', '(', ')', '/', '!',
'%' , '{', '}', '[', ']', '`', '´', '$', '^', '~':
dst.put(cast(char)ch);
break;
case '<': dst.put("&lt;"); break;
case '>': dst.put("&gt;"); break;
case '&': dst.put("&amp;"); break;
} }
} }
enum HTMLEscapeFlags {
escapeMinimal = 0,
escapeQuotes = 1<<0,
escapeNewline = 1<<1,
escapeUnknown = 1<<2
}
/*****************************
*/
import std.conv; import std.conv;
/** /**
A logger that logs in syslog format according to RFC 5424. A logger that logs in syslog format according to RFC 5424.