diff --git a/CHANGELOG.md b/CHANGELOG.md index a59cd4c1a..5ac5ebd52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ creating the URLs for Targetable components and excludes the session token. * Moved the adding of the hidden parameters onto the AJAX url from the XSL into the WApplicationRenderer so the session token can be excluded. +* Updated beanutils version and package names as beanutils had a transient dependency on commons-collections that has security vulnerabilies. + * commons-beanutils:commons-beanutils:1.11.0 to org.apache.commons:commons-beanutils2:2.0.0-M2 +* Updated antisamy to latest version 1.7.8 as it has reinstated the xHTML behaviour for tags. Versions 1.7.0 to 1.7.6 did not support xHTML and would break the XML. + * org.owasp.antisamy:antismay from 1.6.8 to 1.7.8 +* Updated FileUtil to include MetaData hints when calling tika to help tika identify a files content type. ### Bug Fixes diff --git a/wcomponents-core/pom.xml b/wcomponents-core/pom.xml index 1eb6d2cb3..0d3c61620 100755 --- a/wcomponents-core/pom.xml +++ b/wcomponents-core/pom.xml @@ -129,15 +129,19 @@ - commons-beanutils - commons-beanutils - 1.11.0 + org.apache.commons + commons-beanutils2 + 2.0.0-M2 commons-logging commons-logging + + org.apache.commons + commons-lang3 + @@ -224,51 +228,28 @@ - - + org.owasp.antisamy antisamy - 1.6.8 + 1.7.8 - - org.slf4j - slf4j-api - org.apache.xmlgraphics batik-css - - commons-io - commons-io - org.apache.httpcomponents.client5 httpclient5 - - org.apache.httpcomponents.core5 - httpcore5 - - - net.sourceforge.htmlunit - neko-htmlunit - xerces xercesImpl - - - net.sourceforge.htmlunit - neko-htmlunit - 2.70.0 - org.apache.xmlgraphics batik-css diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanBoundTableModel.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanBoundTableModel.java index c99a53923..b9dd89094 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanBoundTableModel.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanBoundTableModel.java @@ -1,7 +1,7 @@ package com.github.bordertech.wcomponents; import com.github.bordertech.wcomponents.WTable.BeanBoundTableModel; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanTableDataModel.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanTableDataModel.java index e230090bd..d55e9a19b 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanTableDataModel.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AbstractBeanTableDataModel.java @@ -1,6 +1,6 @@ package com.github.bordertech.wcomponents; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableDataModel.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableDataModel.java index defa9d8fc..c1a7949b6 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableDataModel.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableDataModel.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java index b7e1b17bd..2c579d292 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java @@ -7,7 +7,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanListTableDataModel.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanListTableDataModel.java index aec0d4d43..e56bd45a7 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanListTableDataModel.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanListTableDataModel.java @@ -6,7 +6,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanTreeTableDataModel.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanTreeTableDataModel.java index 7562fdffd..cbee423d4 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanTreeTableDataModel.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanTreeTableDataModel.java @@ -7,7 +7,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java index ec1cfcb7e..990c77330 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WBeanComponent.java @@ -6,7 +6,7 @@ import java.io.Serializable; import java.util.Map; import java.util.Objects; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java index 584b4e962..8b15189ab 100755 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WRepeater.java @@ -12,7 +12,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java index 248bcffec..c81cbee96 100644 --- a/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java +++ b/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/FileUtil.java @@ -10,6 +10,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tika.Tika; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.metadata.TikaCoreProperties; /** * Utility methods for {@link File}. @@ -98,7 +100,15 @@ public static String getFileMimeType(final File file) { if (file != null) { try { final Tika tika = new Tika(); - return tika.detect(file.getInputStream()); + // Setup metatdata hints to help Tika detect the mime type + Metadata meta = new Metadata(); + if (file.getName() != null) { + meta.set(TikaCoreProperties.RESOURCE_NAME_KEY, file.getName()); + } + if (file.getMimeType() != null) { + meta.set(TikaCoreProperties.CONTENT_TYPE_HINT, file.getMimeType()); + } + return tika.detect(file.getInputStream(), meta); } catch (IOException ex) { LOG.error("Invalid file, name " + file.getName(), ex); } diff --git a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/AbstractWComponentTestCase.java b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/AbstractWComponentTestCase.java index 97f880d56..95619f3c7 100755 --- a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/AbstractWComponentTestCase.java +++ b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/AbstractWComponentTestCase.java @@ -12,7 +12,7 @@ import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Function; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils2.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; diff --git a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WComponentsPerformance_Test.java b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WComponentsPerformance_Test.java index 0cb81141a..e729673b6 100755 --- a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WComponentsPerformance_Test.java +++ b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WComponentsPerformance_Test.java @@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.beanutils2.BeanUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; diff --git a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WMultiFileWidget_Test.java b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WMultiFileWidget_Test.java index 91e1c6ec9..a7126fd0e 100755 --- a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WMultiFileWidget_Test.java +++ b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WMultiFileWidget_Test.java @@ -10,7 +10,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.fileupload.FileItem; import org.junit.Assert; import org.junit.Test; @@ -124,8 +124,6 @@ public void testGetFile() { Assert.assertEquals("File2 should be returned for index 1", TEST_FILE_ITEM_WRAP2, widget. getFile("2")); } - - @Test public void testGetMimeType() { @@ -323,18 +321,18 @@ public void testSetFileTypesAsNullOrEmptyList() { @Test public void testMaxFileSizeAccessors() { assertAccessorsCorrect(new WMultiFileWidget(), WMultiFileWidget::getMaxFileSize, WMultiFileWidget::setMaxFileSize, - 10240000L, 1L, 2L); + 10240000L, 1L, 2L); } @Test public void testDuplicateComponentModels() { WMultiFileWidget multiFileWidget = new WMultiFileWidget(); - assertNoDuplicateComponentModels(multiFileWidget,"maxFileSize", 2012312312); + assertNoDuplicateComponentModels(multiFileWidget, "maxFileSize", 2012312312); assertNoDuplicateComponentModels(multiFileWidget, "maxFiles", 123); assertNoDuplicateComponentModels(multiFileWidget, "newUpload", true); assertNoDuplicateComponentModels(multiFileWidget, "useThumbnails", true); assertNoDuplicateComponentModels(multiFileWidget, "thumbnailPosition", WLink.ImagePosition.SOUTH); - assertNoDuplicateComponentModels(multiFileWidget, "thumbnailSize", new Dimension(22,33)); + assertNoDuplicateComponentModels(multiFileWidget, "thumbnailSize", new Dimension(22, 33)); // TODO: See issue #1574 https://github.com/BorderTech/wcomponents/issues/1574 // assertNoDuplicateComponentModels(multiFileWidget, "fileUploadRequestId", "testId"); // No such method exception as it's a private method } diff --git a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/render/webxml/WLabelRenderer_Test.java b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/render/webxml/WLabelRenderer_Test.java index a2b2cf9cc..89506e316 100755 --- a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/render/webxml/WLabelRenderer_Test.java +++ b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/render/webxml/WLabelRenderer_Test.java @@ -94,12 +94,12 @@ public void testDoPaintAllOptions() throws IOException, SAXException, XpathExcep @Test public void testSanitizedText() throws IOException, SAXException, XpathException { MyInput comp = new MyInput(); - WLabel label = new WLabel("
content

", comp); + WLabel label = new WLabel("
content

", comp); label.setEncodeText(false); label.setSanitizeOnOutput(true); assertSchemaMatch(label); String xml = toXHtml(label); - Assert.assertTrue("Label text should contain sanitized xml", xml.contains("content
")); + Assert.assertTrue("Label text should contain sanitized xml", xml.contains("content
")); } @Test diff --git a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/servlet/WServletPerformance_Test.java b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/servlet/WServletPerformance_Test.java index 703b75a55..09ee638ce 100755 --- a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/servlet/WServletPerformance_Test.java +++ b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/servlet/WServletPerformance_Test.java @@ -29,7 +29,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.beanutils2.BeanUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; diff --git a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/FileUtil_Test.java b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/FileUtil_Test.java index 73403c10e..a490fcc8f 100644 --- a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/FileUtil_Test.java +++ b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/FileUtil_Test.java @@ -1,5 +1,6 @@ package com.github.bordertech.wcomponents.util; +import com.github.bordertech.wcomponents.file.File; import com.github.bordertech.wcomponents.file.FileItemWrap; import com.github.bordertech.wcomponents.util.mock.MockFileItem; import java.io.IOException; @@ -12,6 +13,7 @@ /** * FileUtil_Test - unit test for {@link FileUtil}. + * * @author Aswin Kandula * @since 1.5 */ @@ -32,7 +34,7 @@ public void testValidateFileTypeImageFile() throws IOException { public void testValidateFileTypeAnyFile() throws IOException { boolean validateFileType = FileUtil.validateFileType(null, null); Assert.assertFalse(validateFileType); - + FileItem newFileItem = createFileItem(null); validateFileType = FileUtil.validateFileType(new FileItemWrap(newFileItem), Collections.EMPTY_LIST); Assert.assertTrue(validateFileType); @@ -44,35 +46,35 @@ public void testValidateFileTypePdfFile() throws IOException { boolean validateFileType = FileUtil.validateFileType(new FileItemWrap(newFileItem), Arrays.asList("application/pdf")); Assert.assertTrue(validateFileType); } - + @Test public void testValidateFileTypeTr5File() throws IOException { // 'tr5' file has no mime type, so validation will pass with extension only. FileItem newFileItem = createFileItem("/content/test.tr5"); boolean validateFileType = FileUtil.validateFileType(new FileItemWrap(newFileItem), Arrays.asList(".tr5")); Assert.assertTrue(validateFileType); - + newFileItem = createFileItem("/content/test.tr5"); validateFileType = FileUtil.validateFileType(new FileItemWrap(newFileItem), Arrays.asList("text/plain")); Assert.assertTrue(validateFileType); - + newFileItem = createFileItem("/content/test.tr5"); validateFileType = FileUtil.validateFileType(new FileItemWrap(newFileItem), Arrays.asList("image/jpg")); Assert.assertFalse(validateFileType); } - + @Test public void testValidateFileTypeDodgyTr5File() throws IOException { // 'tr5' file has no mime type, so validation will pass with extension only. FileItem newFileItem = createFileItem("/content/dodgy.pdf.tr5"); boolean validateFileType = FileUtil.validateFileType(new FileItemWrap(newFileItem), Arrays.asList(".tr5")); Assert.assertTrue(validateFileType); - + newFileItem = createFileItem("/content/dodgy.pdf.tr5"); validateFileType = FileUtil.validateFileType(new FileItemWrap(newFileItem), Arrays.asList("text/plain")); Assert.assertFalse(validateFileType); } - + @Test public void testValidateFileSize() throws IOException { FileItem newFileItem = createFileItem(null); @@ -81,20 +83,20 @@ public void testValidateFileSize() throws IOException { validateFileSize = FileUtil.validateFileSize(new FileItemWrap(newFileItem), 50); Assert.assertFalse(validateFileSize); - + FileUtil.validateFileSize(null, 0); Assert.assertFalse(validateFileSize); - + validateFileSize = FileUtil.validateFileSize(new FileItemWrap(newFileItem), -1000); Assert.assertTrue(validateFileSize); } - + @Test public void testReadableFileSize() { String readableFileSize = FileUtil.readableFileSize(10101); Assert.assertEquals("10.1 KB", readableFileSize); } - + @Test public void testGetInvalidFileTypeMessage() { String invalidFileTypeMessage = FileUtil.getInvalidFileTypeMessage(null); @@ -103,16 +105,40 @@ public void testGetInvalidFileTypeMessage() { invalidFileTypeMessage = FileUtil.getInvalidFileTypeMessage(Arrays.asList("*")); Assert.assertEquals("The file you have selected is not of an accepted type. Only the following type/s are accepted: *.", invalidFileTypeMessage); } - + @Test public void testGetInvalidFileSizeMessage() { String invalidFileSizeMessage = FileUtil.getInvalidFileSizeMessage(1111); Assert.assertEquals("The file you have selected is too large. Maximum file size is 1.1 KB.", invalidFileSizeMessage); } - + + @Test + public void testGetMimeTypeForTextFileAndNoHint() throws IOException { + // Tika text detector by default will treat a file with less than 10% non-ascii characters as a text file + // Test Tika detects the file as text with no hint + MyMockFile file = new MyMockFile("/content/text-non-ascii-less-10-per.txt", null, null); + Assert.assertEquals("Incorrect type for text file that should have been detected as text with no hints", "text/plain", FileUtil.getFileMimeType(file)); + } + + @Test + public void testGetMimeTypeForTextFileWithAsciiAndNoHint() throws IOException { + // Tika text detector by default will treat a file with more than 10% non-ascii characters as not a text file + // Test providing no hint of the file name to Tika that it wont detect it as text + MyMockFile file = new MyMockFile("/content/text-non-ascii-more-10-per.txt", null, null); + Assert.assertEquals("Incorrect type for text file that should not be detected as text with no hints", "application/octet-stream", FileUtil.getFileMimeType(file)); + } + + @Test + public void testGetMimeTypeForTextFileWithAsciiAndNameHint() throws IOException { + // Tika text detector by default will treat a file with more than 10% non-ascii characters as not a text file + // Test providing a hint of the file name to Tika will detect it as text + MyMockFile file = new MyMockFile("/content/text-non-ascii-more-10-per.txt", "text-non-ascii-more-10-per.txt", null); + Assert.assertEquals("Incorrect type for text file that should be detected as text with name hint", "text/plain", FileUtil.getFileMimeType(file)); + } + /** * Create a new fileitem. - * + * * @param fileResource if {@code null} dummy byte[] are set on file, otherwise given file resource. * @return a file item */ @@ -123,21 +149,70 @@ private FileItem createFileItem(String fileResource) throws IOException { for (int i = 0; i < testFileContent.length; i++) { testFileContent[i] = (byte) (i & 0xff); } - } - else { + } else { InputStream stream = getClass().getResourceAsStream(fileResource); if (stream == null) { throw new IOException("File resource not found: " + fileResource); } - testFileContent = StreamUtil.getBytes(stream); + testFileContent = StreamUtil.getBytes(stream); } MockFileItem fileItem = new MockFileItem(); fileItem.set(testFileContent); fileItem.setFieldName(fileResource); - if (fileResource != null) { + if (fileResource != null) { String[] tokens = fileResource.split(".+?/(?=[^/]+$)"); fileItem.setName(tokens[1]); } return fileItem; } + + private static class MyMockFile implements File { + + private final String fileResource; + private final String name; + private final String mimeType; + + public MyMockFile(String fileResource, String name, String mimeType) { + this.fileResource = fileResource; + this.name = name; + this.mimeType = mimeType; + } + + @Override + public InputStream getInputStream() throws IOException { + return getClass().getResourceAsStream(fileResource); + } + + @Override + public String getName() { + return name; + } + + @Override + public String getMimeType() { + return mimeType; + } + + @Override + public long getSize() { + throw new UnsupportedOperationException("Not used in test"); + } + + @Override + public String getFileName() { + throw new UnsupportedOperationException("Not used in test"); + } + + @Override + public byte[] getBytes() { + throw new UnsupportedOperationException("Not used in test"); + } + + @Override + public String getDescription() { + throw new UnsupportedOperationException("Not used in test"); + } + + } + } diff --git a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/HtmlSanitizerUtil_Test.java b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/HtmlSanitizerUtil_Test.java index d24f50392..1d9865d4e 100644 --- a/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/HtmlSanitizerUtil_Test.java +++ b/wcomponents-core/src/test/java/com/github/bordertech/wcomponents/util/HtmlSanitizerUtil_Test.java @@ -174,8 +174,8 @@ public void testStrictSanitizerElement() throws ScanException, PolicyException { @Test public void testLaxScanVoidElements() throws ScanException, PolicyException { - // Antisamy as of 1.7.X does not support xhtml and will remove the closing tag on "void" elements which will break the XML - String input = "
"; + // Note - Antisamy 1.7.0 to 1.7.6 does not support xhtml and will remove the closing tag on "void" elements which will break the XML + String input = "
"; Assert.assertEquals(input, HtmlSanitizerUtil.sanitize(input, true)); } diff --git a/wcomponents-core/src/test/resources/content/text-non-ascii-less-10-per.txt b/wcomponents-core/src/test/resources/content/text-non-ascii-less-10-per.txt new file mode 100644 index 000000000..d791c2131 --- /dev/null +++ b/wcomponents-core/src/test/resources/content/text-non-ascii-less-10-per.txt @@ -0,0 +1 @@ +““XXXXXXXXXXXXXXXXXX diff --git a/wcomponents-core/src/test/resources/content/text-non-ascii-more-10-per.txt b/wcomponents-core/src/test/resources/content/text-non-ascii-more-10-per.txt new file mode 100644 index 000000000..95e5b808e --- /dev/null +++ b/wcomponents-core/src/test/resources/content/text-non-ascii-more-10-per.txt @@ -0,0 +1 @@ +“““““XX diff --git a/wcomponents-examples/pom.xml b/wcomponents-examples/pom.xml index 651b7e195..9766f67ea 100755 --- a/wcomponents-examples/pom.xml +++ b/wcomponents-examples/pom.xml @@ -57,19 +57,6 @@ ${project.version}
- - commons-validator - commons-validator - 1.10.0 - - - - commons-logging - commons-logging - - - - com.github.bordertech.wcomponents diff --git a/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/LinkOptionsExample.java b/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/LinkOptionsExample.java index f72556a38..0eac430a5 100755 --- a/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/LinkOptionsExample.java +++ b/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/LinkOptionsExample.java @@ -17,10 +17,12 @@ import com.github.bordertech.wcomponents.WTextField; import com.github.bordertech.wcomponents.validation.ValidatingAction; import com.github.bordertech.wcomponents.validation.WValidationErrors; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.commons.validator.routines.UrlValidator; /** * LinkOptionsExample contains a series of controls for displaying and manipulating an example link. @@ -151,8 +153,12 @@ public void executeOnValid(final ActionEvent event) { * @return true if valid */ private boolean isValidUrl(final String url) { - UrlValidator validator = new UrlValidator(); - return validator.isValid(url); + try { + new URL(url).toURI(); + return true; + } catch (MalformedURLException | URISyntaxException e) { + return false; + } } /** diff --git a/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableOptionsExample.java b/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableOptionsExample.java index 734ac6c95..ae275dcc6 100755 --- a/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableOptionsExample.java +++ b/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableOptionsExample.java @@ -31,7 +31,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -import org.apache.commons.beanutils.BeanComparator; +import org.apache.commons.beanutils2.BeanComparator; /** * This class demonstrates the options available on a {@link WDataTable}. diff --git a/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/WMultiSelectPairTestingExample_Test.java b/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/WMultiSelectPairTestingExample_Test.java index 431c3a874..7ef87a5dd 100644 --- a/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/WMultiSelectPairTestingExample_Test.java +++ b/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/WMultiSelectPairTestingExample_Test.java @@ -5,7 +5,7 @@ import com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver; import com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement; import java.util.List; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WCheckBoxSelectExample_Test.java b/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WCheckBoxSelectExample_Test.java index facecc4bb..4763278af 100644 --- a/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WCheckBoxSelectExample_Test.java +++ b/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WCheckBoxSelectExample_Test.java @@ -7,7 +7,7 @@ import com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver; import com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement; import com.github.bordertech.wcomponents.util.SystemException; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample_Test.java b/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample_Test.java index 75c91604b..e03a6f5a1 100644 --- a/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample_Test.java +++ b/wcomponents-examples/src/test/java/com/github/bordertech/wcomponents/examples/theme/WRadioButtonSelectExample_Test.java @@ -6,7 +6,7 @@ import com.github.bordertech.wcomponents.test.selenium.MultiBrowserRunner; import com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver; import com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/ByLabel.java b/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/ByLabel.java index f5d740464..fe1eb8c30 100644 --- a/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/ByLabel.java +++ b/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/ByLabel.java @@ -4,7 +4,7 @@ import com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebProperties; import java.util.ArrayList; import java.util.List; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.By; import org.openqa.selenium.SearchContext; diff --git a/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/element/SeleniumCheckableGroupInputWebElement.java b/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/element/SeleniumCheckableGroupInputWebElement.java index e37caf0e4..25ad92f1b 100644 --- a/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/element/SeleniumCheckableGroupInputWebElement.java +++ b/wcomponents-test-lib/src/main/java/com/github/bordertech/wcomponents/test/selenium/element/SeleniumCheckableGroupInputWebElement.java @@ -5,7 +5,7 @@ import com.github.bordertech.wcomponents.util.SystemException; import java.util.ArrayList; import java.util.List; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement;