diff options
author | James Moger <james.moger@gitblit.com> | 2013-03-29 10:59:26 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-03-29 10:59:26 -0400 |
commit | f5654729757eedefc1c656ac4be764b6a19ada2e (patch) | |
tree | 5c3420cdc89549fb0a4d6c80654945f1aaec3fbc | |
parent | e5c14e6d7e24bbf6807a65e56560a13e7bd7eca3 (diff) | |
download | gitblit-f5654729757eedefc1c656ac4be764b6a19ada2e.tar.gz gitblit-f5654729757eedefc1c656ac4be764b6a19ada2e.zip |
Add more error checking to blob page
-rw-r--r-- | releases.moxie | 1 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/GitBlitWebApp.properties | 3 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/BlobPage.java | 23 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/panels/CommitHeaderPanel.java | 1 |
4 files changed, 25 insertions, 3 deletions
diff --git a/releases.moxie b/releases.moxie index 8dac1dcb..05989142 100644 --- a/releases.moxie +++ b/releases.moxie @@ -9,6 +9,7 @@ r17: { - Raw servlet was insecure. If someone knew the exact repository name and path to a file, the raw blob could be retrieved bypassing security constraints. (issue 198)
fixes:
- Could not reset settings with $ or { characters through Gitblit Manager because they are not properly escaped
+ - Added more error checking to blob page
- Fix NPE when getting user's fork without repository list caching (issue 182)
- Fix internal error on folder history links (issue 192)
- Fixed incorrect icon file name for .doc files (issue 200)
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index 7a2b1bb3..b0d559f6 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -444,4 +444,5 @@ gb.excludeFromActivity = exclude from activity page gb.isSparkleshared = repository is Sparkleshared
gb.owners = owners
gb.sessionEnded = Session has been closed
-gb.closeBrowser = Please close the browser to properly end the session.
\ No newline at end of file +gb.closeBrowser = Please close the browser to properly end the session.
+gb.doesNotExistInTree = {0} does not exist in tree {1}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java index e2b8546b..ab0f0f16 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java @@ -124,20 +124,39 @@ public class BlobPage extends RepositoryPage { default:
// plain text
String source = JGitUtils.getStringContent(r, commit.getTree(), blobPath, encodings);
- String table = generateSourceView(source, type == 1);
+ String table;
+ if (source == null) {
+ table = missingBlob(blobPath, commit);
+ } else {
+ table = generateSourceView(source, type == 1);
+ }
add(new Label("blobText", table).setEscapeModelStrings(false));
add(new Image("blobImage").setVisible(false));
}
} else {
// plain text
String source = JGitUtils.getStringContent(r, commit.getTree(), blobPath, encodings);
- String table = generateSourceView(source, false);
+ String table;
+ if (source == null) {
+ table = missingBlob(blobPath, commit);
+ } else {
+ table = generateSourceView(source, false);
+ }
add(new Label("blobText", table).setEscapeModelStrings(false));
add(new Image("blobImage").setVisible(false));
}
}
}
+ protected String missingBlob(String blobPath, RevCommit commit) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<div class=\"alert alert-error\">");
+ String pattern = getString("gb.doesNotExistInTree").replace("{0}", "<b>{0}</b>").replace("{1}", "<b>{1}</b>");
+ sb.append(MessageFormat.format(pattern, blobPath, commit.getTree().getId().getName()));
+ sb.append("</div>");
+ return sb.toString();
+ }
+
protected String generateSourceView(String source, boolean prettyPrint) {
String [] lines = source.split("\n");
diff --git a/src/main/java/com/gitblit/wicket/panels/CommitHeaderPanel.java b/src/main/java/com/gitblit/wicket/panels/CommitHeaderPanel.java index bb960cca..eb757501 100644 --- a/src/main/java/com/gitblit/wicket/panels/CommitHeaderPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/CommitHeaderPanel.java @@ -33,6 +33,7 @@ public class CommitHeaderPanel extends BasePanel { add(new Label("commitid"));
add(new Label("author"));
add(new Label("date"));
+ add(new Label("authorAvatar"));
}
public CommitHeaderPanel(String id, String repositoryName, RevCommit c) {
|