From 6fd076a9ef55926deee27e60a0f7f24bb4839f94 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz Date: Sat, 23 Sep 2017 19:20:02 +0200 Subject: [PATCH] gb.xml.html: Fix detection of existing meta charset tags when switching to HTML5 [GB.XML.HTML] * BUG: Fix detection of existing meta charset tags when switching to HTML5. --- gb.xml/src/html/htmldocument.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gb.xml/src/html/htmldocument.cpp b/gb.xml/src/html/htmldocument.cpp index 3fc9eb984..8b70876f4 100644 --- a/gb.xml/src/html/htmldocument.cpp +++ b/gb.xml/src/html/htmldocument.cpp @@ -265,21 +265,23 @@ void UpdateMetaCharset(Document *doc, bool html5) size_t lenMetas; Element **metas = XML.XMLNode_getChildrenByTagName(HtmlDocument_GetHead(doc), "meta", 4, lenMetas, 2); Element *meta = 0; + Element *tmeta = 0; Attribute *attr; for(size_t i = 0; i < lenMetas; i++) { + tmeta = metas[i]; if(doc->docType == XHTMLDocumentType) { - attr = XML.XMLElement_GetAttribute(metas[i], "http-equiv", 11, 0); + attr = XML.XMLElement_GetAttribute(tmeta, "http-equiv", 10, 0); if(!attr) continue; if(!XML.GB_MatchString(attr->attrValue, attr->lenAttrValue, "Content-Type", 12, 0)) continue; - XML.XMLElement_RemoveAttribute(metas[i], attr); - attr = XML.XMLElement_GetAttribute(metas[i], "content", 7, 0); + XML.XMLElement_RemoveAttribute(tmeta, attr); + attr = XML.XMLElement_GetAttribute(tmeta, "content", 7, 0); if(!attr) continue; - if(!XML.GB_MatchString(attr->attrValue, attr->lenAttrValue, "text/html; charset=utf-8", 25, 0)) continue; - XML.XMLElement_RemoveAttribute(metas[i], attr); - meta = metas[i]; + if(!XML.GB_MatchString(attr->attrValue, attr->lenAttrValue, "text/html; charset=utf-8", 24, 0)) continue; + XML.XMLElement_RemoveAttribute(tmeta, attr); + meta = tmeta; break; } else