Skip to content
Snippets Groups Projects
Commit 64841f6a authored by srosse's avatar srosse
Browse files

Merge OpenOLAT 9.3 to OpenOLAT default branch with 362449a4d1b9865aca2a948590ae178a0f50b425

parents aa3bf193 c7896421
No related branches found
No related tags found
No related merge requests found
......@@ -1965,12 +1965,12 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3</version>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3</version>
<version>4.3.1</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
......@@ -1981,7 +1981,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3</version>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
......
......@@ -72,7 +72,6 @@ public class IFrameDeliveryMapper implements Mapper, Serializable {
private boolean enableTextmarking;
private boolean adjusteightAutomatically;
private String g_encoding;
private String jsEncoding;
private String contentEncoding;
......@@ -93,7 +92,6 @@ public class IFrameDeliveryMapper implements Mapper, Serializable {
}
public IFrameDeliveryMapper(VFSItem rootDir, boolean rawContent, boolean enableTextmarking, boolean adjusteightAutomatically,
String g_encoding, String jsEncoding, String contentEncoding,
String frameId, String customCssURL, String themeBaseUri, String customHeaderContent) {
this.rootDir = rootDir;
......@@ -102,10 +100,6 @@ public class IFrameDeliveryMapper implements Mapper, Serializable {
this.enableTextmarking = enableTextmarking;
this.adjusteightAutomatically = adjusteightAutomatically;
this.g_encoding = g_encoding;
this.jsEncoding = jsEncoding;
this.contentEncoding = contentEncoding;
this.frameId = frameId;
this.customCssURL = customCssURL;
this.themeBaseUri = themeBaseUri;
......@@ -121,7 +115,7 @@ public class IFrameDeliveryMapper implements Mapper, Serializable {
}
openolatCss = config.getOpenolatCss();
if(config.getContentEncoding() != null) {
g_encoding = config.getContentEncoding();
contentEncoding = config.getContentEncoding();
}
if(config.getJavascriptEncoding() != null) {
jsEncoding = config.getJavascriptEncoding();
......@@ -202,13 +196,16 @@ public class IFrameDeliveryMapper implements Mapper, Serializable {
if (path.toLowerCase().lastIndexOf(FILE_SUFFIX_HTM) >= (path.length()-4)) {
// set the http content-type and the encoding
Page page = loadPageWithGuess(vfsLeaf);
g_encoding = page.getEncoding();
String pageEncoding = page.getEncoding();
if (page.isUseLoadedPageString()) {
mr = prepareMediaResource(httpRequest, page.getPage(), g_encoding, page.getContentType(), isPopUp);
mr = prepareMediaResource(httpRequest, page.getPage(), pageEncoding, page.getContentType(), isPopUp);
} else {
// found a new charset other than iso-8859-1, load string with proper encoding
String content = FileUtils.load(vfsLeaf.getInputStream(), g_encoding);
mr = prepareMediaResource(httpRequest, content, g_encoding, page.getContentType(), isPopUp);
String content = FileUtils.load(vfsLeaf.getInputStream(), pageEncoding);
mr = prepareMediaResource(httpRequest, content, pageEncoding, page.getContentType(), isPopUp);
}
if(contentEncoding == null) {
contentEncoding = pageEncoding;
}
} else if (path.endsWith(FILE_SUFFIX_JS)) { // a javascript library
VFSMediaResource vmr = new VFSMediaResource(vfsLeaf);
......@@ -218,8 +215,11 @@ public class IFrameDeliveryMapper implements Mapper, Serializable {
// together with the mime-type, which is wrong.
// so we assume the .js file has the same encoding as the html file
// that loads the .js file
if (jsEncoding != null) vmr.setEncoding(jsEncoding);
else if (g_encoding != null) vmr.setEncoding(g_encoding);
if (jsEncoding != null) {
vmr.setEncoding(jsEncoding);
} else if (contentEncoding != null) {
vmr.setEncoding(contentEncoding);
}
mr = vmr;
} else {
// binary data: not .html, not .htm, not .js -> treated as is
......@@ -505,7 +505,7 @@ public class IFrameDeliveryMapper implements Mapper, Serializable {
return cType;
}
private String guessEncoding(String content) {
protected String guessEncoding(String content) {
Matcher m = PATTERN_ENCTYPE.matcher(content);
if (m.find()) {
// use found char set
......
......@@ -157,7 +157,6 @@ public class IFrameDisplayController extends BasicController implements GenericE
//TODO:gs may use the same contentMapper if users clicks again on the same singlePage, now each time a new Mapper gets created and
//therefore the browser can not reuse the cached elements
contentMapper = new IFrameDeliveryMapper(rootDir, false, enableTextmarking, adjusteightAutomatically,
null /*g_encoding*/, null /*jsEncoding*/, null /*contentEncoding*/,
frameId, null /*customCssURL*/, themeBaseUri, null /*customHeaderContent*/);
contentMapper.setDeliveryOptions(options);
......
......@@ -26,6 +26,8 @@
package org.olat.core.gui.media;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException;
......@@ -34,13 +36,18 @@ import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
/**
* @author Mike Stock
*/
public class HttpRequestMediaResource implements MediaResource {
private static final OLog log = Tracing.createLoggerFor(HttpRequestMediaResource.class);
private final HttpResponse response;
......@@ -78,7 +85,7 @@ public class HttpRequestMediaResource implements MediaResource {
try {
return response.getEntity().getContent();
} catch (Exception e) {
//
log.error("", e);
}
return null;
}
......@@ -107,7 +114,9 @@ public class HttpRequestMediaResource implements MediaResource {
*/
@Override
public void release() {
//response.getEntity()..releaseConnection();
if(response instanceof Closeable) {
IOUtils.closeQuietly((Closeable)response);
}
}
/**
......@@ -124,6 +133,5 @@ public class HttpRequestMediaResource implements MediaResource {
} else {
hres.setHeader("Content-Disposition", "filename=" + h.getValue());
}
}
}
\ No newline at end of file
......@@ -38,6 +38,7 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.olat.basesecurity.BaseSecurityModule;
import org.olat.core.CoreSpringFactory;
import org.olat.core.dispatcher.mapper.Mapper;
......@@ -144,6 +145,7 @@ public class TunnelMapper implements Mapper {
Header responseHeader = response.getFirstHeader("Content-Type");
if (responseHeader == null) {
// error
EntityUtils.consumeQuietly(response.getEntity());
return new NotFoundMediaResource(relPath);
}
return new HttpRequestMediaResource(response);
......@@ -154,7 +156,7 @@ public class TunnelMapper implements Mapper {
log.error("", e);
return null;
} catch (IOException e) {
log.error("", e);
log.error("Error loading URI: " + (meth == null ? "???" : meth.getURI()), e);
return null;
}
}
......
......@@ -22,6 +22,7 @@ package org.olat.search.ui;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
......@@ -235,10 +236,16 @@ public class AdvancedSearchInputController extends FormBasicController {
appendAnd(queries, AbstractOlatDocument.DESCRIPTION_FIELD_NAME, ":(", descriptionQuery.getValue(), ") ");
}
if (StringHelper.containsNonWhitespace(createdDate.getValue())) {
appendAnd(queries, AbstractOlatDocument.CREATED_FIELD_NAME, ":(", format.format(createdDate.getDate()), ") ");
Date creationDate = createdDate.getDate();
if(creationDate != null) {
appendAnd(queries, AbstractOlatDocument.CREATED_FIELD_NAME, ":(", format.format(creationDate), ") ");
}
}
if (StringHelper.containsNonWhitespace(modifiedDate.getValue())) {
appendAnd(queries, AbstractOlatDocument.CHANGED_FIELD_NAME, ":(", format.format(modifiedDate.getDate()), ") ");
Date modificationDate = modifiedDate.getDate();
if(modificationDate != null) {
appendAnd(queries, AbstractOlatDocument.CHANGED_FIELD_NAME, ":(", format.format(modificationDate), ") ");
}
}
//Check for null on metadata element since it might not be configured and initialized
if (metadataQuery != null && StringHelper.containsNonWhitespace(metadataQuery.getValue())) {
......
......@@ -230,15 +230,19 @@ public class ShibbolethDispatcher implements Dispatcher{
if(attributesMap.keySet().size()==1) {
return false;
}
String lastname = attributesMap.get(ShibbolethModule.getLastName());
String firstname = attributesMap.get(ShibbolethModule.getFirstName());
String email = ShibbolethHelper.getFirstValueOf(ShibbolethModule.getEMail(), attributesMap);
String institutionalEMail = ShibbolethHelper.getFirstValueOf(ShibbolethModule.getInstitutionalEMail(), attributesMap);
String institutionalName = attributesMap.get(ShibbolethModule.getInstitutionalName());
//String institutionalUserIdentifier = userMapping.getInstitutionalUserIdentifier();
if(lastname!=null && !lastname.equals("") && firstname!=null && !firstname.equals("") && email!=null && !email.equals("") &&
institutionalEMail!=null && !institutionalEMail.equals("") && institutionalName!=null && !institutionalName.equals("")) {
return true;
try {
String lastname = attributesMap.get(ShibbolethModule.getLastName());
String firstname = attributesMap.get(ShibbolethModule.getFirstName());
String email = ShibbolethHelper.getFirstValueOf(ShibbolethModule.getEMail(), attributesMap);
String institutionalEMail = ShibbolethHelper.getFirstValueOf(ShibbolethModule.getInstitutionalEMail(), attributesMap);
String institutionalName = attributesMap.get(ShibbolethModule.getInstitutionalName());
//String institutionalUserIdentifier = userMapping.getInstitutionalUserIdentifier();
if(lastname!=null && !lastname.equals("") && firstname!=null && !firstname.equals("") && email!=null && !email.equals("") &&
institutionalEMail!=null && !institutionalEMail.equals("") && institutionalName!=null && !institutionalName.equals("")) {
return true;
}
} catch (IllegalArgumentException e) {
log.error("Error when reading Shib attributes. Either home org not allowed to connect to this OO instance or user has missing attributes.");
}
return false;
}
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.core.gui.control.generic.iframe;
import junit.framework.Assert;
import org.junit.Test;
/**
*
* Initial date: 03.02.2014<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class IFrameDeliveryMapperTest {
@Test
public void testPatternRegex() {
IFrameDeliveryMapper mapper = new IFrameDeliveryMapper();
String encoding1 = mapper.guessEncoding("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
Assert.assertEquals("utf-8", encoding1);
String encoding2 = mapper.guessEncoding("<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>");
Assert.assertEquals("UTF-8", encoding2);
}
}
......@@ -66,6 +66,7 @@ import org.junit.runners.Suite;
org.olat.core.id.context.HistoryManagerTest.class,
org.olat.core.id.IdentityEnvironmentTest.class,
org.olat.core.gui.render.VelocityTemplateTest.class,
org.olat.core.gui.control.generic.iframe.IFrameDeliveryMapperTest.class,
org.olat.note.NoteTest.class,//ok
org.olat.user.UserPropertiesPerformanceTest.class,//ok
org.olat.user.EmailCheckPerformanceTest.class,//fail
......
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