diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-11-03 14:45:33 +0100 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-11-03 14:45:33 +0100 |
commit | adf9c7f968c387b8b5641e4fcf253a2b3512db4d (patch) | |
tree | c8f340da6c40634da40753917d56e7e7dc7e10c6 /pdf-over-gui/src/main/java/at | |
parent | da0513c70d6599e2432d6a9fb24eada781856b0c (diff) | |
download | pdf-over-adf9c7f968c387b8b5641e4fcf253a2b3512db4d.tar.gz pdf-over-adf9c7f968c387b8b5641e4fcf253a2b3512db4d.tar.bz2 pdf-over-adf9c7f968c387b8b5641e4fcf253a2b3512db4d.zip |
more generic error page detection (grml why no uniquely identifiable id...) cf. #130
Diffstat (limited to 'pdf-over-gui/src/main/java/at')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java index 03ddd0c3..7978187d 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java @@ -93,15 +93,26 @@ public class ATrustParser { private ErrorBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed { super(htmlDocument, formOptions); - if (!htmlDocument.baseUri().contains("/error.aspx")) + + try { + String documentPath = new URI(htmlDocument.baseUri()).getPath(); + String aspxFile = documentPath.substring(documentPath.lastIndexOf('/')); + + // gods this is such a hack, why can't they have a proper error element or something + if (!(aspxFile.startsWith("/error") && aspxFile.endsWith(".aspx"))) + throw new ComponentParseFailed(); + } catch (URISyntaxException ex) { + log.warn("Failed to parse document base URI as URI? ({})", htmlDocument.baseUri()); throw new ComponentParseFailed(); - + } + this.isRecoverable = (htmlDocument.selectFirst("#Button_Back") != null); - String errorText = getElementEnsureNotNull("#Label1").ownText(); - if (errorText.startsWith("Fehler:")) - errorText = errorText.substring(7); - this.errorText = ISNOTNULL(errorText.trim()); + StringBuilder errorText = new StringBuilder(getElementEnsureNotNull("#Label1").ownText().trim()); + var detailLabel = this.htmlDocument.selectFirst("#LabelDetail"); + if (detailLabel != null) + errorText.append("\n").append(detailLabel.ownText().trim()); + this.errorText = ISNOTNULL(errorText.toString()); } } |