diff --git a/src/html.c b/src/html.c index 343dd5e..d3eaf14 100644 --- a/src/html.c +++ b/src/html.c @@ -855,12 +855,19 @@ transform_html_ucs2 (RECODE_SUBTASK subtask) valid = false; } } + else /* Not '#' or A-z, so not a valid entity. */ + { + valid = false; + /* Push back '&', but do not output current input_char yet. */ + *cursor = '\0'; + } if (echo || !valid) { recode_put_ucs2 ('&', subtask); for (cursor = buffer; *cursor; cursor++) recode_put_ucs2 (*cursor, subtask); + /* input_char is processed again in the next iteration. */ } } else diff --git a/tests/t40_html.py b/tests/t40_html.py new file mode 100644 index 0000000..763ae99 --- /dev/null +++ b/tests/t40_html.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +import common +from common import setup_module, teardown_module + +input = '& S&P, S & P, &' +output = '& S&P, S & P, &' + +class Test: + def test_1(self): + common.request('html..') + common.validate(input, output)