Prevent infinite recursion with nested table and textarea
Bug-Debian: https://github.com/tats/w3m/issues/20#issuecomment-260590257
This commit is contained in:
@@ -6448,6 +6448,7 @@ HTMLlineproc0(char *line, struct html_feed_environ *h_env, int internal)
|
|||||||
do_blankline(h_env, obuf, indent, 0, h_env->limit);
|
do_blankline(h_env, obuf, indent, 0, h_env->limit);
|
||||||
}
|
}
|
||||||
save_fonteffect(h_env, obuf);
|
save_fonteffect(h_env, obuf);
|
||||||
|
initRenderTable();
|
||||||
renderTable(tbl, tbl_width, h_env);
|
renderTable(tbl, tbl_width, h_env);
|
||||||
restore_fonteffect(h_env, obuf);
|
restore_fonteffect(h_env, obuf);
|
||||||
obuf->flag &= ~RB_IGNORE_P;
|
obuf->flag &= ~RB_IGNORE_P;
|
||||||
|
|||||||
@@ -393,6 +393,7 @@ extern void align(TextLine *lbuf, int width, int mode);
|
|||||||
extern void print_item(struct table *t, int row, int col, int width, Str buf);
|
extern void print_item(struct table *t, int row, int col, int width, Str buf);
|
||||||
extern void print_sep(struct table *t, int row, int type, int maxcol, Str buf);
|
extern void print_sep(struct table *t, int row, int type, int maxcol, Str buf);
|
||||||
extern void do_refill(struct table *tbl, int row, int col, int maxlimit);
|
extern void do_refill(struct table *tbl, int row, int col, int maxlimit);
|
||||||
|
extern void initRenderTable(void);
|
||||||
extern void renderTable(struct table *t, int max_width,
|
extern void renderTable(struct table *t, int max_width,
|
||||||
struct html_feed_environ *h_env);
|
struct html_feed_environ *h_env);
|
||||||
extern struct table *begin_table(int border, int spacing, int padding,
|
extern struct table *begin_table(int border, int spacing, int padding,
|
||||||
|
|||||||
@@ -1623,6 +1623,15 @@ get_table_width(struct table *t, short *orgwidth, short *cellwidth, int flag)
|
|||||||
#define fixed_table_width(t)\
|
#define fixed_table_width(t)\
|
||||||
(get_table_width(t,t->fixed_width,t->cell.fixed_width,CHECK_MINIMUM))
|
(get_table_width(t,t->fixed_width,t->cell.fixed_width,CHECK_MINIMUM))
|
||||||
|
|
||||||
|
#define MAX_COTABLE_LEVEL 100
|
||||||
|
static int cotable_level;
|
||||||
|
|
||||||
|
void
|
||||||
|
initRenderTable(void)
|
||||||
|
{
|
||||||
|
cotable_level = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
renderCoTable(struct table *tbl, int maxlimit)
|
renderCoTable(struct table *tbl, int maxlimit)
|
||||||
{
|
{
|
||||||
@@ -1633,6 +1642,10 @@ renderCoTable(struct table *tbl, int maxlimit)
|
|||||||
int i, col, row;
|
int i, col, row;
|
||||||
int indent, maxwidth;
|
int indent, maxwidth;
|
||||||
|
|
||||||
|
if (cotable_level >= MAX_COTABLE_LEVEL)
|
||||||
|
return; /* workaround to prevent infinite recursion */
|
||||||
|
cotable_level++;
|
||||||
|
|
||||||
for (i = 0; i < tbl->ntable; i++) {
|
for (i = 0; i < tbl->ntable; i++) {
|
||||||
t = tbl->tables[i].ptr;
|
t = tbl->tables[i].ptr;
|
||||||
col = tbl->tables[i].col;
|
col = tbl->tables[i].col;
|
||||||
|
|||||||
Reference in New Issue
Block a user