* htmlCheckImplied: * @ctxt: an HTML parser context * @newtag: The new tag name * * The HTML DTD allows a tag to exists only implicitly * called when a new tag has been detected and generates the * appropriates implicit tags if missing */
| 1551 | * appropriates implicit tags if missing |
| 1552 | */ |
| 1553 | static void |
| 1554 | htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { |
| 1555 | int i; |
| 1556 | |
| 1557 | if (ctxt->options & HTML_PARSE_NOIMPLIED) |
| 1558 | return; |
| 1559 | if (!htmlOmittedDefaultValue) |
| 1560 | return; |
| 1561 | if (xmlStrEqual(newtag, BAD_CAST"html")) |
| 1562 | return; |
| 1563 | if (ctxt->nameNr <= 0) { |
| 1564 | htmlnamePush(ctxt, BAD_CAST"html"); |
| 1565 | if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) |
| 1566 | ctxt->sax->startElement(ctxt->userData, BAD_CAST"html", NULL); |
| 1567 | } |
| 1568 | if ((xmlStrEqual(newtag, BAD_CAST"body")) || (xmlStrEqual(newtag, BAD_CAST"head"))) |
| 1569 | return; |
| 1570 | if ((ctxt->nameNr <= 1) && |
| 1571 | ((xmlStrEqual(newtag, BAD_CAST"script")) || |
| 1572 | (xmlStrEqual(newtag, BAD_CAST"style")) || |
| 1573 | (xmlStrEqual(newtag, BAD_CAST"meta")) || |
| 1574 | (xmlStrEqual(newtag, BAD_CAST"link")) || |
| 1575 | (xmlStrEqual(newtag, BAD_CAST"title")) || |
| 1576 | (xmlStrEqual(newtag, BAD_CAST"base")))) { |
| 1577 | if (ctxt->html >= 3) { |
| 1578 | /* we already saw or generated an <head> before */ |
| 1579 | return; |
| 1580 | } |
| 1581 | /* |
| 1582 | * dropped OBJECT ... i you put it first BODY will be |
| 1583 | * assumed ! |
| 1584 | */ |
| 1585 | htmlnamePush(ctxt, BAD_CAST"head"); |
| 1586 | if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) |
| 1587 | ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL); |
| 1588 | } else if ((!xmlStrEqual(newtag, BAD_CAST"noframes")) && |
| 1589 | (!xmlStrEqual(newtag, BAD_CAST"frame")) && |
| 1590 | (!xmlStrEqual(newtag, BAD_CAST"frameset"))) { |
| 1591 | if (ctxt->html >= 10) { |
| 1592 | /* we already saw or generated a <body> before */ |
| 1593 | return; |
| 1594 | } |
| 1595 | for (i = 0;i < ctxt->nameNr;i++) { |
| 1596 | if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"body")) { |
| 1597 | return; |
| 1598 | } |
| 1599 | if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"head")) { |
| 1600 | return; |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | htmlnamePush(ctxt, BAD_CAST"body"); |
| 1605 | if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) |
| 1606 | ctxt->sax->startElement(ctxt->userData, BAD_CAST"body", NULL); |
| 1607 | } |
| 1608 | } |
| 1609 | |
| 1610 | /** |
no test coverage detected