Skip to content
Snippets Groups Projects
Commit 575d2077 authored by srosse's avatar srosse
Browse files

OO-4453: fix substring of url in single page

parent b6553c82
No related branches found
No related tags found
No related merge requests found
...@@ -336,28 +336,25 @@ public class IFrameDisplayController extends BasicController implements GenericE ...@@ -336,28 +336,25 @@ public class IFrameDisplayController extends BasicController implements GenericE
setPageDownload(isPageDownloadAllowed(currentUri)); setPageDownload(isPageDownloadAllowed(currentUri));
} }
private boolean isPageDownloadAllowed(String uri) { private boolean isPageDownloadAllowed(final String uri) {
if(!allowDownload || !StringHelper.containsNonWhitespace(uri)) { if(!allowDownload || !StringHelper.containsNonWhitespace(uri)) {
return false; return false;
} }
// remove any URL parameters // remove any URL parameters
String uriLc = uri.toLowerCase(); String uriLc = uri.toLowerCase();
int qmarkPos = uriLc.indexOf("?"); int qmarkPos = uriLc.indexOf('?');
if (qmarkPos != -1) { if (qmarkPos != -1) {
// e.g. index.html?olatraw=true // e.g. index.html?olatraw=true
uriLc = uriLc.substring(0, qmarkPos); uriLc = uriLc.substring(0, qmarkPos);
} }
// remove any anchor references // remove any anchor references
int hTagPos = uri.indexOf("#"); int hTagPos = uriLc.indexOf('#');
if (hTagPos != -1) { if (hTagPos != -1) {
// e.g. index.html#checkThisOut // e.g. index.html#checkThisOut
uriLc = uriLc.substring(0, hTagPos); uriLc = uriLc.substring(0, hTagPos);
} }
// HTML pages are rendered inline, everything else is regarded as "downloadable" // HTML pages are rendered inline, everything else is regarded as "downloadable"
if(uriLc.endsWith(".html") || uriLc.endsWith(".htm") || uriLc.endsWith(".xhtml")) { return !uriLc.endsWith(".html") && !uriLc.endsWith(".htm") && !uriLc.endsWith(".xhtml");
return false;
}
return true;
} }
private void setPageDownload(boolean allow) { private void setPageDownload(boolean allow) {
...@@ -385,8 +382,7 @@ public class IFrameDisplayController extends BasicController implements GenericE ...@@ -385,8 +382,7 @@ public class IFrameDisplayController extends BasicController implements GenericE
if (NEW_URI_EVENT.equals(event.getCommand())) { if (NEW_URI_EVENT.equals(event.getCommand())) {
// This event gets triggered from the iframe content by calling a js function outside // This event gets triggered from the iframe content by calling a js function outside
// Get new uri from JS method and fire to parents // Get new uri from JS method and fire to parents
String newUri = ureq.getModuleURI(); String newUri = ureq.getHttpReq().getParameter("uri");
newUri = ureq.getHttpReq().getParameter("uri");
int baseUriPos = newUri.indexOf(baseURI); int baseUriPos = newUri.indexOf(baseURI);
if (baseUriPos != -1) { if (baseUriPos != -1) {
int newUriPos = baseUriPos + baseURI.length(); int newUriPos = baseUriPos + baseURI.length();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment