Todays implementation processed only <option> tags inside an optgroup. If the optgroup is not closed correctly in the HTML code, all tags after this will be ignored. Browsers seems to close the optgroup if there are other tags then <option>.
It seems to be a better idea to close the optgroup if an unknown tag was found instead of ignoring these tags. This should give better results on buggy HTML code.
Can you provide a test case? How does Tidy (the C program) handle it?