{
guint l, rep_len;
gchar *t = s, *h = s, *e = s, *end_ptr;
+ const gchar *end;
const gchar *entity;
gint state = 0, val, base;
khiter_t k;
l = len;
}
+ end = s + l;
+
while (h - s < (gint)l) {
switch (state) {
/* Out of entity */
if (kh_val (html_entity_by_name, k)) {
rep_len = strlen (kh_val (html_entity_by_name, k));
- if (end_ptr - t >= rep_len) {
+ if (end - t >= rep_len) {
memcpy (t, kh_val (html_entity_by_name, k),
rep_len);
t += rep_len;
}
} else {
- if (end_ptr - t >= h - e) {
+ if (end - t >= h - e) {
memmove (t, e, h - e);
t += h - e;
}
if (end_ptr != NULL && *end_ptr != '\0') {
/* Skip undecoded */
- if (end_ptr - t >= h - e) {
+ if (end - t >= h - e) {
memmove (t, e, h - e);
t += h - e;
}
if (kh_val (html_entity_by_number, k)) {
rep_len = strlen (kh_val (html_entity_by_number, k));
- if (end_ptr - t >= rep_len) {
+ if (end - t >= rep_len) {
memcpy (t, kh_val (html_entity_by_number, k),
rep_len);
t += rep_len;
}
} else {
- if (end_ptr - t >= h - e) {
+ if (end - t >= h - e) {
memmove (t, e, h - e);
t += h - e;
}
local t = rspamd_util.parse_html(c[1])
assert_not_nil(t)
- assert_equal(c[2], tostring(t))
+ assert_equal(c[2], tostring(t), string.format("'%s' doesn't match with '%s'",
+ c[2], t))
end
end)
end)