changeset 195:890bb568427b

- Added nesting checks for BUTTON, SELECT and FORM.
author jcid
date Sun, 27 Apr 2008 18:18:14 +0200
parents e32a99e4bac8
children 928e1de0b626
files ChangeLog src/html.cc
diffstat 2 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Apr 27 15:55:09 2008 +0200
+++ b/ChangeLog	Sun Apr 27 18:18:14 2008 +0200
@@ -94,6 +94,7 @@
  - Implemented ISINDEX.
  - Added input image for FORMS.
  - Added button for FORMS.
+ - Added nesting checks for BUTTON, SELECT and FORM.
    Patches: place
 +- Fixed a problem with locally-installed dpis.
  - Added code for optional image loading (nice interface) very advanced!
--- a/src/html.cc	Sun Apr 27 15:55:09 2008 +0200
+++ b/src/html.cc	Sun Apr 27 18:18:14 2008 +0200
@@ -2572,6 +2572,12 @@
       MSG_HTML("<button> element outside <form>\n");
       return;
    }
+   if (html->InFlags & IN_BUTTON) {
+      MSG_HTML("nested <button>\n");
+      return;
+   }
+   html->InFlags |= IN_BUTTON;
+
    form = html->forms->getRef (html->forms->size() - 1);
    type = Html_get_attr_wdef(html, tag, tagsize, "type", "");
 
@@ -2635,6 +2641,15 @@
 }
 
 /*
+ * Handle close <BUTTON>
+ */
+static void Html_tag_close_button(DilloHtml *html, int TagIdx)
+{
+   html->InFlags &= ~IN_BUTTON;
+   Html_pop_tag(html, TagIdx);
+}
+
+/*
  * <FONT>
  */
 static void Html_tag_open_font(DilloHtml *html, const char *tag, int tagsize)
@@ -4492,6 +4507,14 @@
       MSG_HTML("<input> element outside <form>\n");
       return;
    }
+   if (html->InFlags & IN_SELECT) {
+      MSG_HTML("<input> element inside <select>\n");
+      return;
+   }
+   if (html->InFlags & IN_BUTTON) {
+      MSG_HTML("<input> element inside <button>\n");
+      return;
+   }
   
    form = html->forms->getRef (html->forms->size() - 1);
   
@@ -4664,6 +4687,11 @@
    Embed *embed;
    const char *attrbuf;
 
+   if (html->InFlags & IN_FORM) {
+      MSG("<isindex> inside <form> not handled.\n");
+      return;
+   }
+
    if ((attrbuf = Html_get_attr(html, tag, tagsize, "action")))
       action = Html_url_new(html, attrbuf, NULL, 0, 0, 0, 0);
    else
@@ -5160,7 +5188,7 @@
  {"blockquote", B8(011110),'R',2,Html_tag_open_blockquote,Html_tag_close_par},
  {"body", B8(011110),'O',1, Html_tag_open_body, Html_tag_close_body},
  {"br", B8(010001),'F',0, Html_tag_open_br, Html_tag_close_default},
- {"button", B8(011101),'R',2, Html_tag_open_button, Html_tag_close_default},
+ {"button", B8(011101),'R',2, Html_tag_open_button, Html_tag_close_button},
  /* caption */
  {"center", B8(011110),'R',2, Html_tag_open_center, Html_tag_close_div},
  {"cite", B8(010101),'R',2, Html_tag_open_cite, Html_tag_close_default},