2009-02-05 14:21:47 +00:00
|
|
|
/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.berlios.de>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#include "htmlescape.hh"
|
|
|
|
|
|
|
|
namespace Html {
|
|
|
|
|
|
|
|
string escape( string const & str )
|
|
|
|
{
|
|
|
|
string result( str );
|
|
|
|
|
|
|
|
for( size_t x = result.size(); x--; )
|
|
|
|
switch ( result[ x ] )
|
|
|
|
{
|
|
|
|
case '&':
|
|
|
|
result.erase( x, 1 );
|
|
|
|
result.insert( x, "&" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '<':
|
|
|
|
result.erase( x, 1 );
|
|
|
|
result.insert( x, "<" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '>':
|
|
|
|
result.erase( x, 1 );
|
|
|
|
result.insert( x, ">" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '"':
|
|
|
|
result.erase( x, 1 );
|
|
|
|
result.insert( x, """ );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|