Skip to content
Snippets Groups Projects
Commit 4b9110a9 authored by srosse's avatar srosse
Browse files

OO-3841: update spring, commons, bouncycastle and poi

parent 84a4b7b8
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<targetJdk>1.8</targetJdk> <targetJdk>1.8</targetJdk>
<org.springframework.version>5.1.4.RELEASE</org.springframework.version> <org.springframework.version>5.1.5.RELEASE</org.springframework.version>
<org.hibernate.version>5.4.1.Final</org.hibernate.version> <org.hibernate.version>5.4.1.Final</org.hibernate.version>
<com.sun.jersey.version>1.19.4</com.sun.jersey.version> <com.sun.jersey.version>1.19.4</com.sun.jersey.version>
<apache.cxf>3.2.7</apache.cxf> <apache.cxf>3.2.7</apache.cxf>
...@@ -1790,7 +1790,7 @@ ...@@ -1790,7 +1790,7 @@
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
<version>1.11</version> <version>1.12</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- Used by at least commons-validator --> <!-- Used by at least commons-validator -->
...@@ -1802,7 +1802,7 @@ ...@@ -1802,7 +1802,7 @@
<!-- Used by email address validator --> <!-- Used by email address validator -->
<groupId>commons-validator</groupId> <groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId> <artifactId>commons-validator</artifactId>
<version>1.5.0</version> <version>1.6</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
...@@ -1874,12 +1874,12 @@ ...@@ -1874,12 +1874,12 @@
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>3.17</version> <version>4.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId> <artifactId>poi-scratchpad</artifactId>
<version>3.17</version> <version>4.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.pdfbox</groupId> <groupId>org.apache.pdfbox</groupId>
...@@ -1906,12 +1906,12 @@ ...@@ -1906,12 +1906,12 @@
<dependency> <dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId> <artifactId>bcmail-jdk15on</artifactId>
<version>1.60</version> <version>1.61</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId> <artifactId>bcprov-jdk15on</artifactId>
<version>1.60</version> <version>1.61</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.scribe</groupId> <groupId>org.scribe</groupId>
...@@ -2209,7 +2209,7 @@ ...@@ -2209,7 +2209,7 @@
<dependency> <dependency>
<groupId>com.opencsv</groupId> <groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId> <artifactId>opencsv</artifactId>
<version>4.4</version> <version>4.5</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
...@@ -2469,7 +2469,7 @@ ...@@ -2469,7 +2469,7 @@
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<version>3.6.1</version> <version>3.12.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -2481,7 +2481,7 @@ ...@@ -2481,7 +2481,7 @@
<dependency> <dependency>
<groupId>xmlunit</groupId> <groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId> <artifactId>xmlunit</artifactId>
<version>1.5</version> <version>1.6</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -2499,7 +2499,7 @@ ...@@ -2499,7 +2499,7 @@
<dependency> <dependency>
<groupId>org.zapodot</groupId> <groupId>org.zapodot</groupId>
<artifactId>embedded-ldap-junit</artifactId> <artifactId>embedded-ldap-junit</artifactId>
<version>0.5.2</version> <version>0.7</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -2518,7 +2518,7 @@ ...@@ -2518,7 +2518,7 @@
<dependency> <dependency>
<groupId>org.jboss.arquillian.container</groupId> <groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-tomcat-managed-7</artifactId> <artifactId>arquillian-tomcat-managed-7</artifactId>
<version>1.0.0</version> <version>1.1.0.Final</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -2529,7 +2529,7 @@ ...@@ -2529,7 +2529,7 @@
<dependency> <dependency>
<groupId>org.eu.ingwar.tools</groupId> <groupId>org.eu.ingwar.tools</groupId>
<artifactId>arquillian-suite-extension</artifactId> <artifactId>arquillian-suite-extension</artifactId>
<version>1.1.4</version> <version>1.2.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -39,7 +39,6 @@ public class EmailAddressValidator { ...@@ -39,7 +39,6 @@ public class EmailAddressValidator {
*/ */
public static boolean isValidEmailAddress(String mailAddress) { public static boolean isValidEmailAddress(String mailAddress) {
// Validate an email address // Validate an email address
boolean isAddressValid = validator.isValid(mailAddress); return validator.isValid(mailAddress);
return isAddressValid;
} }
} }
...@@ -65,17 +65,16 @@ class GetDocumentByCallable implements Callable<Document> { ...@@ -65,17 +65,16 @@ class GetDocumentByCallable implements Callable<Document> {
public Document call() { public Document call() {
Document doc = null; Document doc = null;
IndexSearcher searcher = null; IndexSearcher searcher = null;
try { try(KeywordAnalyzer analyzer=new KeywordAnalyzer()) {
if (searchService.existIndex()) { if (searchService.existIndex()) {
searcher = searchService.getIndexSearcher(); searcher = searchService.getIndexSearcher();
String url = Encoder.md5hash(resourceUrl); String url = Encoder.md5hash(resourceUrl);
String queryStr = "+" + AbstractOlatDocument.RESOURCEURL_MD5_FIELD_NAME + ":\"" + url + "\""; String queryStr = "+" + AbstractOlatDocument.RESOURCEURL_MD5_FIELD_NAME + ":\"" + url + "\"";
QueryParser idQueryParser = new QueryParser(queryStr, new KeywordAnalyzer()); QueryParser idQueryParser = new QueryParser(queryStr, analyzer);
Query query = idQueryParser.parse(queryStr); Query query = idQueryParser.parse(queryStr);
TopDocs docs = searcher.search(query, 500); TopDocs docs = searcher.search(query, 500);
long numOfDocs = docs.totalHits; long numOfDocs = docs.totalHits;
Set<String> retrievedFields = new HashSet<>(); Set<String> retrievedFields = new HashSet<>();
retrievedFields.add(AbstractOlatDocument.RESOURCEURL_FIELD_NAME); retrievedFields.add(AbstractOlatDocument.RESOURCEURL_FIELD_NAME);
......
...@@ -75,9 +75,8 @@ public class ExcelDocument extends FileDocument { ...@@ -75,9 +75,8 @@ public class ExcelDocument extends FileDocument {
int sheetNullCounter = 0; int sheetNullCounter = 0;
try(BufferedInputStream bis = new BufferedInputStream(leaf.getInputStream()); try(BufferedInputStream bis = new BufferedInputStream(leaf.getInputStream());
HSSFWorkbook workbook = new HSSFWorkbook(new POIFSFileSystem(bis));) { HSSFWorkbook workbook = new HSSFWorkbook(new POIFSFileSystem(bis));
LimitedContentWriter content = new LimitedContentWriter((int)leaf.getSize(), FileDocumentFactory.getMaxFileSize())) {
LimitedContentWriter content = new LimitedContentWriter((int)leaf.getSize(), FileDocumentFactory.getMaxFileSize());
for (int sheetNumber = 0; sheetNumber < workbook.getNumberOfSheets(); sheetNumber++) { for (int sheetNumber = 0; sheetNumber < workbook.getNumberOfSheets(); sheetNumber++) {
HSSFSheet sheet = workbook.getSheetAt(sheetNumber); HSSFSheet sheet = workbook.getSheetAt(sheetNumber);
if (sheet != null) { if (sheet != null) {
...@@ -87,7 +86,7 @@ public class ExcelDocument extends FileDocument { ...@@ -87,7 +86,7 @@ public class ExcelDocument extends FileDocument {
for (int cellNumber = row.getFirstCellNum(); cellNumber <= row.getLastCellNum(); cellNumber++) { for (int cellNumber = row.getFirstCellNum(); cellNumber <= row.getLastCellNum(); cellNumber++) {
HSSFCell cell = row.getCell(cellNumber); HSSFCell cell = row.getCell(cellNumber);
if (cell != null) { if (cell != null) {
if (cell.getCellTypeEnum() == CellType.STRING) { if (cell.getCellType() == CellType.STRING) {
content.append(cell.getStringCellValue()).append(' '); content.append(cell.getStringCellValue()).append(' ');
} }
} else { } else {
...@@ -108,7 +107,6 @@ public class ExcelDocument extends FileDocument { ...@@ -108,7 +107,6 @@ public class ExcelDocument extends FileDocument {
+ sheetNullCounter); + sheetNullCounter);
} }
} }
content.close();
return new FileContent(content.toString()); return new FileContent(content.toString());
} catch (Exception ex) { } catch (Exception ex) {
throw new DocumentException("Can not read XLS Content. File=" + leaf.getName(), ex); throw new DocumentException("Can not read XLS Content. File=" + leaf.getName(), ex);
......
...@@ -81,16 +81,17 @@ public class ExcelOOXMLDocument extends FileDocument { ...@@ -81,16 +81,17 @@ public class ExcelOOXMLDocument extends FileDocument {
private String parseSheets(Map<String,String> sharedStrings, VFSLeaf leaf) throws IOException, DocumentException { private String parseSheets(Map<String,String> sharedStrings, VFSLeaf leaf) throws IOException, DocumentException {
try(InputStream stream = leaf.getInputStream(); try(InputStream stream = leaf.getInputStream();
ZipInputStream zip = new ZipInputStream(stream)) { ZipInputStream zip = new ZipInputStream(stream);
LimitedContentWriter writer = new LimitedContentWriter(100000, FileDocumentFactory.getMaxFileSize())) {
ZipEntry entry = zip.getNextEntry(); ZipEntry entry = zip.getNextEntry();
LimitedContentWriter writer = new LimitedContentWriter(100000, FileDocumentFactory.getMaxFileSize());
while (entry != null) { while (entry != null) {
if(writer.accept()) { if(writer.accept()) {
String name = entry.getName(); String name = entry.getName();
if(name.startsWith(SHEET) && name.endsWith(".xml")) { if(name.startsWith(SHEET) && name.endsWith(".xml")) {
OfficeDocumentHandler dh = new OfficeDocumentHandler(writer, sharedStrings); OfficeDocumentHandler dh = new OfficeDocumentHandler(writer, sharedStrings);
parse(new ShieldInputStream(zip), dh); parse(zip, dh);
} }
} }
entry = zip.getNextEntry(); entry = zip.getNextEntry();
...@@ -112,7 +113,7 @@ public class ExcelOOXMLDocument extends FileDocument { ...@@ -112,7 +113,7 @@ public class ExcelOOXMLDocument extends FileDocument {
while (entry != null) { while (entry != null) {
String name = entry.getName(); String name = entry.getName();
if(name.endsWith("xl/sharedStrings.xml")) { if(name.endsWith("xl/sharedStrings.xml")) {
parse(new ShieldInputStream(zip), dh); parse(zip, dh);
break; break;
} }
entry = zip.getNextEntry(); entry = zip.getNextEntry();
...@@ -125,8 +126,8 @@ public class ExcelOOXMLDocument extends FileDocument { ...@@ -125,8 +126,8 @@ public class ExcelOOXMLDocument extends FileDocument {
} }
} }
private void parse(InputStream stream, DefaultHandler handler) throws DocumentException { private void parse(ZipInputStream zip, DefaultHandler handler) throws DocumentException {
try { try(InputStream in=new ShieldInputStream(zip)) {
XMLReader parser = XMLReaderFactory.createXMLReader(); XMLReader parser = XMLReaderFactory.createXMLReader();
parser.setContentHandler(handler); parser.setContentHandler(handler);
parser.setEntityResolver(handler); parser.setEntityResolver(handler);
...@@ -135,7 +136,7 @@ public class ExcelOOXMLDocument extends FileDocument { ...@@ -135,7 +136,7 @@ public class ExcelOOXMLDocument extends FileDocument {
} catch(Exception e) { } catch(Exception e) {
log.error("Cannot deactivate validation", e); log.error("Cannot deactivate validation", e);
} }
parser.parse(new InputSource(stream)); parser.parse(new InputSource(in));
} catch (Exception e) { } catch (Exception e) {
throw new DocumentException("XML parser configuration error", e); throw new DocumentException("XML parser configuration error", e);
} }
......
...@@ -71,8 +71,8 @@ public class PowerPointDocument extends FileDocument { ...@@ -71,8 +71,8 @@ public class PowerPointDocument extends FileDocument {
@Override @Override
public FileContent readContent(VFSLeaf leaf) throws IOException,DocumentException { public FileContent readContent(VFSLeaf leaf) throws IOException,DocumentException {
if (log.isDebug()) log.debug("read PPT Content of leaf=" + leaf.getName()); if (log.isDebug()) log.debug("read PPT Content of leaf=" + leaf.getName());
try (BufferedInputStream bis = new BufferedInputStream(leaf.getInputStream())) { try (BufferedInputStream bis = new BufferedInputStream(leaf.getInputStream());
LimitedContentWriter oStream = new LimitedContentWriter(100000, FileDocumentFactory.getMaxFileSize()); LimitedContentWriter oStream = new LimitedContentWriter(100000, FileDocumentFactory.getMaxFileSize())) {
extractText(bis, oStream); extractText(bis, oStream);
return new FileContent(oStream.toString()); return new FileContent(oStream.toString());
} catch (Exception e) { } catch (Exception e) {
...@@ -98,10 +98,8 @@ public class PowerPointDocument extends FileDocument { ...@@ -98,10 +98,8 @@ public class PowerPointDocument extends FileDocument {
public void processPOIFSReaderEvent(POIFSReaderEvent event) { public void processPOIFSReaderEvent(POIFSReaderEvent event) {
int errorCounter = 0; int errorCounter = 0;
try { try(DocumentInputStream dis = event.getStream()) {
DocumentInputStream dis = event.getStream(); byte[] btoWrite = new byte[dis.available()];
byte btoWrite[] = new byte[dis.available()];
dis.read(btoWrite, 0, dis.available()); dis.read(btoWrite, 0, dis.available());
for (int i = 0; i < btoWrite.length - 20; i++) { for (int i = 0; i < btoWrite.length - 20; i++) {
long type = LittleEndian.getUShort(btoWrite, i + 2); long type = LittleEndian.getUShort(btoWrite, i + 2);
...@@ -133,8 +131,7 @@ public class PowerPointDocument extends FileDocument { ...@@ -133,8 +131,7 @@ public class PowerPointDocument extends FileDocument {
private String removeUnvisibleChars(String inputString) { private String removeUnvisibleChars(String inputString) {
Pattern p = Pattern.compile("[^a-zA-Z0-9\n\r!&#<>{}]"); Pattern p = Pattern.compile("[^a-zA-Z0-9\n\r!&#<>{}]");
Matcher m = p.matcher(inputString); Matcher m = p.matcher(inputString);
String output = m.replaceAll(" "); return m.replaceAll(" ");
return output;
} }
} }
} }
...@@ -21,8 +21,6 @@ package org.olat.core.util.mail; ...@@ -21,8 +21,6 @@ package org.olat.core.util.mail;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** /**
* Description:<br> * Description:<br>
...@@ -32,10 +30,10 @@ import org.junit.runners.JUnit4; ...@@ -32,10 +30,10 @@ import org.junit.runners.JUnit4;
* Initial Date: 14.07.2009 <br> * Initial Date: 14.07.2009 <br>
* @author gnaegi * @author gnaegi
*/ */
@RunWith(JUnit4.class)
public class EmailAddressValidatorTest { public class EmailAddressValidatorTest {
@Test public void testPlainText() { @Test
public void testPlainText() {
// correct stuff // correct stuff
Assert.assertTrue(EmailAddressValidator.isValidEmailAddress("contact@openolat.org")); Assert.assertTrue(EmailAddressValidator.isValidEmailAddress("contact@openolat.org"));
Assert.assertTrue(EmailAddressValidator.isValidEmailAddress("hello.world@crazy.world")); Assert.assertTrue(EmailAddressValidator.isValidEmailAddress("hello.world@crazy.world"));
......
...@@ -165,5 +165,7 @@ public class OfficeDocumentTest extends OlatTestCase { ...@@ -165,5 +165,7 @@ public class OfficeDocumentTest extends OlatTestCase {
Assert.assertNotNull(content); Assert.assertNotNull(content);
String body = content.getContent(); String body = content.getContent();
Assert.assertTrue(body.contains("Sample Powerpoint Slide")); Assert.assertTrue(body.contains("Sample Powerpoint Slide"));
Assert.assertTrue(body.contains("Service Release 1"));
Assert.assertTrue(body.contains("full text search"));
} }
} }
\ No newline at end of file
No preview for this file type
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