Remove public HTML escaping declarations from log module.
This commit is contained in:
parent
d06ad74ee3
commit
2071f30a1c
|
@ -520,72 +520,22 @@ final class HTMLLogger : Logger {
|
|||
</html>`);
|
||||
m_logFile.flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Helper stuff.
|
||||
*/
|
||||
/** Writes the HTML escaped version of a given string to an output range.
|
||||
*/
|
||||
void filterHTMLEscape(R, S)(ref R dst, S str, HTMLEscapeFlags flags = HTMLEscapeFlags.escapeNewline)
|
||||
if (isOutputRange!(R, dchar) && isInputRange!S)
|
||||
{
|
||||
for (;!str.empty;str.popFront())
|
||||
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 )
|
||||
{
|
||||
private static void filterHTMLEscape(R, S)(ref R dst, S str)
|
||||
{
|
||||
for (;!str.empty;str.popFront()) {
|
||||
auto ch = str.front;
|
||||
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(""");
|
||||
else dst.put('"');
|
||||
break;
|
||||
case '\'':
|
||||
if (flags & HTMLEscapeFlags.escapeQuotes) dst.put("'");
|
||||
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;
|
||||
default: dst.put(ch); break;
|
||||
case '<': dst.put("<"); break;
|
||||
case '>': dst.put(">"); break;
|
||||
case '&': dst.put("&"); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum HTMLEscapeFlags {
|
||||
escapeMinimal = 0,
|
||||
escapeQuotes = 1<<0,
|
||||
escapeNewline = 1<<1,
|
||||
escapeUnknown = 1<<2
|
||||
}
|
||||
/*****************************
|
||||
*/
|
||||
|
||||
import std.conv;
|
||||
/**
|
||||
A logger that logs in syslog format according to RFC 5424.
|
||||
|
|
Loading…
Reference in a new issue