xmlsafe
An XML writer that protects you from XML injections through type safety.
-
three marker traits mark the XML safety of
Display
implementations -
the streaming
XmlWriter
requires its arguments to implement these traits -
a
tag!
macro to structure your code (plays well withrustfmt
)
If you forget to escape a string, your code just doesn't compile. To prevent XML injections keep two things in mind:
-
Whenever you supply a string literal (
&'static str
), take care that it is syntactically valid for the respective context. -
Whenever you implement one of the marker traits, take care that you fulfill its requirements.
Example
use Error;
use ;
Note how the XmlWriter
acts as a protective layer between the actual
write target (the String in our example) and the XML generation code. Also
note that if we forgot the escape_text
call, the example would not
compile.
Safety
xmlsafe forbids unsafe
code and does not panic.