Commit 6c2c6477 authored by Felix Morgner's avatar Felix Morgner

merge with upstream

parents 8ddbf84c ec497d5d
......@@ -99,6 +99,65 @@
#include <macros.h>
#include <kicad_string.h>
/**
* Function XmlEsc
* translates '<' to "&lt;", '>' to "&gt;" and so on, according to the spec:
* http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
* May be moved to a library if needed generally, but not expecting that.
*/
static wxString XmlEsc( const wxString& aStr, bool isAttribute = false )
{
wxString escaped;
escaped.reserve( aStr.length() );
for( wxString::const_iterator it = aStr.begin(); it != aStr.end(); ++it )
{
const wxChar c = *it;
switch( c )
{
case wxS( '<' ):
escaped.append( wxS( "&lt;" ) );
break;
case wxS( '>' ):
escaped.append( wxS( "&gt;" ) );
break;
case wxS( '&' ):
escaped.append( wxS( "&amp;" ) );
break;
case wxS( '\r' ):
escaped.append( wxS( "&#xD;" ) );
break;
default:
if( isAttribute )
{
switch( c )
{
case wxS( '"' ):
escaped.append( wxS( "&quot;" ) );
break;
case wxS( '\t' ):
escaped.append( wxS( "&#x9;" ) );
break;
case wxS( '\n' ):
escaped.append( wxS( "&#xA;" ));
break;
default:
escaped.append(c);
}
}
else
escaped.append(c);
}
}
return escaped;
}
SVG_PLOTTER::SVG_PLOTTER()
{
m_graphics_changed = true;
......@@ -460,10 +519,10 @@ bool SVG_PLOTTER::StartPlot()
fprintf( outputFile,
"<title>SVG Picture created as %s date %s </title>\n",
TO_UTF8( wxFileName( filename ).GetFullName() ), date_buf );
TO_UTF8( XmlEsc( wxFileName( filename ).GetFullName() ) ), date_buf );
// End of header
fprintf( outputFile, " <desc>Picture generated by %s </desc>\n",
TO_UTF8( creator ) );
TO_UTF8( XmlEsc( creator ) ) );
// output the pen and brush color (RVB values in hex) and opacity
double opacity = 1.0; // 0.0 (transparent to 1.0 (solid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment