Skip to content
Permalink
Browse files
ANY23-524 fix invalid href attribute (#216)
  • Loading branch information
NcIgor committed Oct 22, 2021
1 parent 8daf7d3 commit 5d3a5498545d4534a44492897831719f616a5cfc
Showing 3 changed files with 41 additions and 2 deletions.
@@ -81,8 +81,13 @@ public void run(ExtractionParameters extractionParameters, ExtractionContext ext
}

private boolean extractLink(Node firstLink, BNode subject, IRI documentIRI) throws ExtractionException {
String href = firstLink.getAttributes().getNamedItem("href").getNodeValue();
String rel = firstLink.getAttributes().getNamedItem("rel").getNodeValue();
Node hrefNodeItem = firstLink.getAttributes().getNamedItem("href");
Node relNodeItem = firstLink.getAttributes().getNamedItem("rel");
if (hrefNodeItem == null || relNodeItem == null) {
return false;
}
String href = hrefNodeItem.getNodeValue();
String rel = relNodeItem.getNodeValue();

String[] rels = rel.split("\\s+");
IRI link = document.resolveIRI(href);
@@ -138,6 +138,13 @@ public void testSomeLinksWithoutRel() throws RepositoryException {
assertContains(null, null, charliesHomepage);
}

@Test
public void testSomeLinksWithIncorrectHrefAttribute() throws RepositoryException {
assertExtract("/microformats/xfn/some-links-with-incorrect-href.html");
assertNotContains(null, null, alicesHomepage);
assertContains(null, vXFN.mePage, charliesHomepage);
}

@Test
public void testForSomeReasonICantBeMyOwnSweetheart() throws RepositoryException {
assertExtract("/microformats/xfn/me-and-sweetheart.html");
@@ -0,0 +1,27 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<p>I'm Bob and my friends are<a v-bind:href="http://alice.example.com/" rel="friend">Alice</a>,
and <a href="http://charlie.example.com/" rel="friend">Charlie</a>.
</p>
</body>
</html>

0 comments on commit 5d3a549

Please sign in to comment.