From ce3f4bd24c330e0cace6a31567e1516dfaa66234 Mon Sep 17 00:00:00 2001 From: Christian Aistleitner <christian@quelltextlich.at> Date: Sun, 24 Mar 2013 20:42:23 -0400 Subject: [PATCH] Fix NPE when getting user's fork without repository list caching (issue-182) --- src/com/gitblit/utils/FileUtils.java | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/src/com/gitblit/utils/FileUtils.java b/src/com/gitblit/utils/FileUtils.java index 0834867..a21b512 100644 --- a/src/com/gitblit/utils/FileUtils.java +++ b/src/com/gitblit/utils/FileUtils.java @@ -274,4 +274,19 @@ return path.getAbsoluteFile(); } } + + public static File resolveParameter(String parameter, File aFolder, String path) { + if (aFolder == null) { + // strip any parameter reference + path = path.replace(parameter, "").trim(); + if (path.length() > 0 && path.charAt(0) == '/') { + // strip leading / + path = path.substring(1); + } + } else if (path.contains(parameter)) { + // replace parameter with path + path = path.replace(parameter, aFolder.getAbsolutePath()); + } + return new File(path); + } } -- Gitblit v1.9.1