diff options
author | Florian Zschocke <florian.zschocke@devolo.de> | 2019-11-11 16:24:45 +0100 |
---|---|---|
committer | Florian Zschocke <florian.zschocke@devolo.de> | 2019-11-11 16:24:45 +0100 |
commit | c4698341d75ef4adc38ebbc3bfbca81bf0ed80dc (patch) | |
tree | 6b22a891c7ffc71bcaad1c5f105a64f09dbeb6b0 /src | |
parent | 9bde5212feeafc17dbbf71d190a9d644512267be (diff) | |
download | gitblit-c4698341d75ef4adc38ebbc3bfbca81bf0ed80dc.tar.gz gitblit-c4698341d75ef4adc38ebbc3bfbca81bf0ed80dc.zip |
Guard docs pages against bad URLs
If, for example, an external site links to a docs page or a specific
doc page, and the branch that link points to is no longer existing,
an internal error happens due to a NPE.
The NPE is guarded against and a No Docs page is returned.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/DocPage.java | 5 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/DocsPage.java | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/DocPage.java b/src/main/java/com/gitblit/wicket/pages/DocPage.java index 5d711343..6e76f1cd 100644 --- a/src/main/java/com/gitblit/wicket/pages/DocPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DocPage.java @@ -51,6 +51,11 @@ public class DocPage extends RepositoryPage { Repository r = getRepository();
RevCommit commit = JGitUtils.getCommit(r, objectId);
+ if (commit == null) {
+ setResponsePage(NoDocsPage.class, params);
+ return;
+ }
+
String [] encodings = getEncodings();
// Read raw markup content and transform it to html
diff --git a/src/main/java/com/gitblit/wicket/pages/DocsPage.java b/src/main/java/com/gitblit/wicket/pages/DocsPage.java index 52443862..f87d5134 100644 --- a/src/main/java/com/gitblit/wicket/pages/DocsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DocsPage.java @@ -62,6 +62,10 @@ public class DocsPage extends RepositoryPage { final boolean userCanEdit = currentUser.canEdit(getRepositoryModel());
RevCommit head = JGitUtils.getCommit(r, objectId);
+ if (head == null) {
+ setResponsePage(NoDocsPage.class, params);
+ return;
+ }
final String commitId = getBestCommitId(head);
List<String> extensions = processor.getAllExtensions();
|