Merge branch 'stable-4.5'

* stable-4.5:
  Use the same variable to check and extract LFS object id

Change-Id: I314bd4373f40843c68853b3999f60d85e08628d9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2016-12-06 16:55:16 +09:00
commit c62933bf59
1 changed files with 3 additions and 2 deletions

View File

@ -128,13 +128,14 @@ protected void doGet(HttpServletRequest req,
private AnyLongObjectId getObjectToTransfer(HttpServletRequest req,
HttpServletResponse rsp) throws IOException {
String info = req.getPathInfo();
if (info.length() != 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH) {
int length = 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH;
if (info.length() != length) {
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat
.format(LfsServerText.get().invalidPathInfo, info));
return null;
}
try {
return LongObjectId.fromString(info.substring(1, 65));
return LongObjectId.fromString(info.substring(1, length));
} catch (InvalidLongObjectIdException e) {
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage());
return null;