merge with upstream

This commit is contained in:
Felix Morgner 2013-04-27 17:58:38 -04:00
commit 6c2c647703
1 changed files with 61 additions and 2 deletions

View File

@ -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)