Skip to content

Commit 6d1ef16

Browse files
committed
getStaticElementsByTagName() has to check for prefix
1 parent 6f32e52 commit 6d1ef16

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/java/org/htmlunit/html/DomElement.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,10 @@ public <E extends HtmlElement> List<E> getStaticElementsByTagName(final String t
663663
for (final Iterator<HtmlElement> iterator = this.new DescendantHtmlElementsIterator(); iterator.hasNext();) {
664664
final HtmlElement elem = iterator.next();
665665
if (elem.getLocalName().equalsIgnoreCase(tagName)) {
666-
res.add((E) elem);
666+
final String prefix = elem.getPrefix();
667+
if (prefix == null || prefix.isEmpty()) {
668+
res.add((E) elem);
669+
}
667670
}
668671
}
669672
return res;

src/test/java/org/htmlunit/html/HtmlPage3Test.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,4 +687,24 @@ public void getElementById_AfterAppendingToNewlyCreatedElement() throws Exceptio
687687
+ "</body></html>";
688688
loadPageVerifyTitle2(content);
689689
}
690+
691+
/**
692+
* When looking for the refresh meta tag don't get confused by stuff with a namespace.
693+
* @throws Exception if the test fails
694+
*/
695+
@Test
696+
@Alerts("works")
697+
public void metaWithNamespace() throws Exception {
698+
final String content =
699+
"<html>\n"
700+
+ "<head>\n"
701+
+ " <title>works\u00a7</title>\n"
702+
+ "</head>\n"
703+
+ "<body>\n"
704+
+ " <overheidrg:meta xmlns:overheidrg='http://standaarden.overheid.nl/cvdr/terms/'>\n"
705+
+ "</body>\n"
706+
+ "</html>";
707+
708+
loadPageVerifyTitle2(content);
709+
}
690710
}

0 commit comments

Comments
 (0)