Skip to content

Commit

Permalink
html.c: fix handling of invalid entities (fix #58, thanks @ccbenny)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrthomas committed Sep 13, 2024
1 parent 483e401 commit aecbbe0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/t40_html.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit aecbbe0

Please sign in to comment.