Ticket #91: omega-htmlparser-ignore-javascript-lessthan.patch
File omega-htmlparser-ignore-javascript-lessthan.patch, 1.5 KB (added by , 18 years ago) |
---|
-
htmlparse.h
30 28 class HtmlParser { 31 29 protected: 32 30 void decode_entities(string &s); 31 bool in_script; 33 32 static map<string, unsigned int> named_ents; 34 33 public: 35 34 virtual void process_text(const string &/*text*/) { } -
htmlparse.cc
240 240 void 241 241 HtmlParser::parse_html(const string &body) 242 242 { 243 in_script = false; 244 243 245 map<string,string> Param; 244 246 string::const_iterator start = body.begin(); 245 247 … … 253 255 if (p == body.end()) break; 254 256 char ch = *(p + 1); 255 257 // Tag, closing tag, comment (or SGML declaration), or PHP. 256 if ( isalpha(ch) || ch == '/' || ch == '!' || ch == '?') break;258 if ((!in_script && isalpha(ch)) || ch == '/' || ch == '!' || ch == '?') break; 257 259 p++; 258 260 } 259 261 … … 338 340 339 341 if (closing) { 340 342 closing_tag(tag); 343 if (in_script && tag == "script") in_script = false; 341 344 342 345 /* ignore any bogus parameters on closing tags */ 343 346 p = find(start, body.end(), '>'); … … 393 396 opening_tag(tag, Param); 394 397 Param.clear(); 395 398 399 // In <script> tags we ignore opening tags to avoid problems with "a<b". 400 if (tag == "script") in_script = true; 401 396 402 if (start != body.end() && *start == '>') ++start; 397 403 } 398 404 }