fix: do not unescape xml sequences in filter mode

This commit is contained in:
Tomasz Sowa 2022-06-01 05:17:30 +02:00
parent 68fe25c8bf
commit 44bda888b5
2 changed files with 11 additions and 2 deletions

View File

@ -63,6 +63,7 @@ void HTMLParser::clear_input_flags()
char_was_escaped = false;
escaped_chars_buffer.clear();
escaped_char_index = 0;
filter_mode = false;
}
@ -173,6 +174,7 @@ void HTMLParser::filter(const wchar_t * in, std::wstring & out, bool clear_out_s
pchar_unicode = in;
out_string = &out;
filter_mode = true;
if( clear_out_string )
out_string->clear();
@ -209,8 +211,8 @@ void HTMLParser::filter(const WTextStream & in, Stream & out, bool clear_out_str
wtext_stream_iterator = &begin;
wtext_stream_iterator_end = &end;
out_stream = &out;
filter_mode = true;
if( clear_out_stream )
out_stream->clear();
@ -232,6 +234,7 @@ HTMLParser::Status HTMLParser::filter_file(const char * file_name, std::wstring
file.open(file_name, std::ios_base::binary | std::ios_base::in);
out_string = &out;
filter_mode = true;
if( clear_out_stream )
out_string->clear();
@ -2383,7 +2386,7 @@ int HTMLParser::read_char()
{
read_char_no_escape();
if( lastc == '&' )
if( !filter_mode && lastc == '&' )
{
read_xml_entity();

View File

@ -310,6 +310,12 @@ protected:
std::wstring escaped_chars_buffer;
size_t escaped_char_index;
/*
* filter mode, a method filter(...) was called
* in filter mode we do not unescape xml sequences such as < > ...
*/
bool filter_mode;
void clear_input_flags();