google / gitiles

A simple browser for Git repositories.
https://gerrit.googlesource.com/gitiles/
Other
582 stars 174 forks source link

StringIndexOutOfBoundsException: String index out of range #83

Closed spearce closed 7 years ago

spearce commented 7 years ago

Originally reported on Google Code with ID 91

What steps will reproduce the problem?
1. Browse to a commit on a project that resides in a subfolder on the server, so you're
looking at something like: http://review.example.com/plugins/gitiles/subfolder/projectname/+/sha1
2. Click on subfolder

What is the expected output? What do you see instead?

500 internal server error.

What version of the product are you using? On what operating system?

Gerrit 2.12-rc1 with gitiles plugin built from 490a649.

Please provide any additional information below.

I can't reproduce this on my local dev instance with 2.12-rc2, but throwing it out
here in case anyone else gets it and can reproduce.

Reported by None on 2015-12-07 03:04:23

spearce commented 7 years ago
What steps will reproduce the problem?
1. Browse to a commit on a project that resides in a subfolder on the server, so you're
looking at something like: http://review.example.com/plugins/gitiles/subfolder/projectname/+/sha1
2. Click on subfolder

What is the expected output? What do you see instead?

500 internal server error.

What version of the product are you using? On what operating system?

Gerrit 2.12-rc1 with gitiles plugin built from 490a649.

Please provide any additional information below.

I can't reproduce this on my local dev instance with 2.12-rc2, but throwing it out
here in case anyone else gets it and can reproduce.

Reported by None on 2015-12-07 03:04:23

spearce commented 7 years ago
Forgot to include the log:

http://paste.openstack.org/show/481001/

Reported by None on 2015-12-07 03:07:57

spearce commented 7 years ago
I managed to reproduce it:

On a site with the gitiles plugin installed, create two projects: 'a' and 'foo/bar'.

Browse to the 'foo/bar' project:

 http://review.example.com/plugins/gitiles/foo/bar

click the 'foo' link.  This results in in the 'Server Error' page and in the log:

  String index out of range: -3

Root cause seems to be that HostIndexServlet.toSoyMapData calls:

  stripPrefix(prefix, desc.name)

which in turn calls

  name.substring(prefix.length() + 1)

In this case prefix is "foo" (length 3) and name is "a" (length 1).

So "a".substring("foo".length() + 1) is what causes the index error.

Reported by None on 2015-12-07 21:55:16

spearce commented 7 years ago
https://gerrit-review.googlesource.com/#/c/73070/

Reported by None on 2015-12-07 22:15:53

spearce commented 7 years ago

Reported by None on 2015-12-09 16:43:46