| 2275 | */ |
| 2276 | |
| 2277 | static int areBlanks(htmlParserCtxtPtr ctxt, const xmlChar *str, int len) { |
| 2278 | unsigned int i; |
| 2279 | int j; |
| 2280 | xmlNodePtr lastChild; |
| 2281 | xmlDtdPtr dtd; |
| 2282 | |
| 2283 | for (j = 0;j < len;j++) |
| 2284 | if (!(IS_BLANK_CH(str[j]))) return(0); |
| 2285 | |
| 2286 | if (CUR == 0) return(1); |
| 2287 | if (CUR != '<') return(0); |
| 2288 | if (ctxt->name == NULL) |
| 2289 | return(1); |
| 2290 | if (xmlStrEqual(ctxt->name, BAD_CAST"html")) |
| 2291 | return(1); |
| 2292 | if (xmlStrEqual(ctxt->name, BAD_CAST"head")) |
| 2293 | return(1); |
| 2294 | |
| 2295 | /* Only strip CDATA children of the body tag for strict HTML DTDs */ |
| 2296 | if (xmlStrEqual(ctxt->name, BAD_CAST "body") && ctxt->myDoc != NULL) { |
| 2297 | dtd = xmlGetIntSubset(ctxt->myDoc); |
| 2298 | if (dtd != NULL && dtd->ExternalID != NULL) { |
| 2299 | if (!xmlStrcasecmp(dtd->ExternalID, BAD_CAST "-//W3C//DTD HTML 4.01//EN") || |
| 2300 | !xmlStrcasecmp(dtd->ExternalID, BAD_CAST "-//W3C//DTD HTML 4//EN")) |
| 2301 | return(1); |
| 2302 | } |
| 2303 | } |
| 2304 | |
| 2305 | if (ctxt->node == NULL) return(0); |
| 2306 | lastChild = xmlGetLastChild(ctxt->node); |
| 2307 | while ((lastChild) && (lastChild->type == XML_COMMENT_NODE)) |
| 2308 | lastChild = lastChild->prev; |
| 2309 | if (lastChild == NULL) { |
| 2310 | if ((ctxt->node->type != XML_ELEMENT_NODE) && |
| 2311 | (ctxt->node->content != NULL)) return(0); |
| 2312 | /* keep ws in constructs like ...<b> </b>... |
| 2313 | for all tags "b" allowing PCDATA */ |
| 2314 | for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) { |
| 2315 | if ( xmlStrEqual(ctxt->name, BAD_CAST allowPCData[i]) ) { |
| 2316 | return(0); |
| 2317 | } |
| 2318 | } |
| 2319 | } else if (xmlNodeIsText(lastChild)) { |
| 2320 | return(0); |
| 2321 | } else { |
| 2322 | /* keep ws in constructs like <p><b>xy</b> <i>z</i><p> |
| 2323 | for all tags "p" allowing PCDATA */ |
| 2324 | for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) { |
| 2325 | if ( xmlStrEqual(lastChild->name, BAD_CAST allowPCData[i]) ) { |
| 2326 | return(0); |
| 2327 | } |
| 2328 | } |
| 2329 | } |
| 2330 | return(1); |
| 2331 | } |
| 2332 | |
| 2333 | /** |
| 2334 | * htmlNewDocNoDtD: |
no test coverage detected