Skip to content

Commit

Permalink
Issue 49447: HTMLDataLoader isHeaderMatch() to catch DOMException for…
Browse files Browse the repository at this point in the history
… JSoupUtil.convertHtmlToDocument (#5148)
  • Loading branch information
cnathe authored Jan 22, 2024
1 parent 02b5efe commit 7ac77bf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions api/src/org/labkey/api/reader/HTMLDataLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.labkey.api.util.FileType;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.JSoupUtil;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -82,12 +83,19 @@ public boolean isHeaderMatch(@NotNull byte[] header)
String s = new String(header, StringUtilsLabKey.DEFAULT_CHARSET);

List<String> errors = new ArrayList<>();
Document doc = JSoupUtil.convertHtmlToDocument(s, true, errors);
if (!errors.isEmpty() || doc == null)
return false;
try
{
Document doc = JSoupUtil.convertHtmlToDocument(s, true, errors);
if (!errors.isEmpty() || doc == null)
return false;

// Look for a html>body>table element
return findTable(doc) != null;
// Look for a html>body>table element
return findTable(doc) != null;
}
catch (DOMException e)
{
return false;
}
}
};

Expand Down

0 comments on commit 7ac77bf

Please sign in to comment.