Skip to content
Browse files

DS-1089 Feedback form breaks when hostname is short

Fix for a string index out of bounds error
  • Loading branch information...
1 parent 9e24d11 commit fe51054727a51abbe2f6d74a879c7e572685178f @ryscher ryscher committed with Feb 27, 2013
View
11 ...e-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/SendFeedbackAction.java
@@ -81,7 +81,16 @@ public Map act(Redirector redirector, SourceResolver resolver, Map objectModel,
// cut off all but the hostname, to cover cases where more than one URL
// arrives at the installation; e.g. presence or absence of "www"
int lastDot = host.lastIndexOf('.');
- basicHost = host.substring(host.substring(0, lastDot).lastIndexOf('.'));
+ int dotBeforeLast = host.substring(0, lastDot).lastIndexOf(".");
+
+ if(dotBeforeLast < 0)
+ {
+ basicHost = host;
+ }
+ else
+ {
+ basicHost = host.substring(dotBeforeLast);
+ }
}
if ((fromPage == null) || ((fromPage.indexOf(basicHost) == -1) && (!validReferral)))

0 comments on commit fe51054

Please sign in to comment.
Something went wrong with that request. Please try again.