Skip to content

Commit

Permalink
Merge pull request sakaiproject#1321 from ouit0408/SAK-30097
Browse files Browse the repository at this point in the history
SAK-30097 Removed hostname(server-url) from site-info url while
  • Loading branch information
buckett committed Jan 29, 2016
2 parents c0d8eb1 + e37ed99 commit 1c15ae6
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ else if (SPECIAL_WORKSITE.equals(special))
String infoUrl = StringUtils.trimToNull(s.getInfoUrl());
if (infoUrl != null)
{
//Check if infoUrl is relative? and prepend the server url
if(infoUrl.startsWith("/") && !infoUrl.contains("://")){
infoUrl = ServerConfigurationService.getServerUrl() + infoUrl;
}
context.put("info_url", FormattedText.escapeHtmlFormattedTextarea(infoUrl));
}

Expand Down Expand Up @@ -869,9 +873,13 @@ else if (newPageTitle.length() > MAX_TITLE_LENGTH)
// Handle the infoUrl
if (SPECIAL_WORKSITE.equals(special))
{
if ((infoUrl != null) && (infoUrl.length() > 0) && (!infoUrl.startsWith("/")) && (infoUrl.indexOf("://") == -1))
{
infoUrl = "http://" + infoUrl;
//Check info-url for null and empty
if(StringUtils.isNotBlank(infoUrl)){
// If the site info url has server url then make it a relative link.
String serverName = new URL(ServerConfigurationService.getServerUrl()).getHost();
// if the supplied url starts with protocol//serverName:port/
Pattern serverUrlPattern = Pattern.compile(String.format("^(https?:)?//%s:?\\d*/", serverName));
infoUrl = serverUrlPattern.matcher(infoUrl).replaceFirst("/");
}
String description = StringUtils.trimToNull(request.getParameter("description"));
//Need to save this processed
Expand Down

0 comments on commit 1c15ae6

Please sign in to comment.