Skip to content

Commit f1426eb

Browse files
authored
Merge pull request #43 from support-project/develop
Release v1.5.0
2 parents 3fff3ef + 1522ede commit f1426eb

File tree

7 files changed

+88
-8
lines changed

7 files changed

+88
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: java
22
jdk: oraclejdk8
33

4-
install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true
4+
install: mvn -U clean install -DskipTests=true -Dmaven.javadoc.skip=true
55
script: mvn test site
66

LICENSE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@
4040
- License: [Creative Commons Attribution-ShareAlike 3.0 license] http://creativecommons.org/licenses/by-sa/3.0/
4141
- project-url: https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project
4242

43+
- Apache Directory LDAP API
44+
- License: [Apache License, Version 2.0] http://www.apache.org/licenses/LICENSE-2.0
45+
- project-url: http://directory.apache.org/api/
46+

deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /bin/bash
2-
mvn clean deploy -DperformRelease=true -Dmaven.javadoc.skip=true -e
2+
mvn clean deploy -DperformRelease=true -e

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.support-project</groupId>
66
<artifactId>web</artifactId>
7-
<version>1.4.0</version>
7+
<version>1.5.0</version>
88
<packaging>jar</packaging>
99

1010
<name>web</name>
@@ -59,7 +59,7 @@
5959
<dependency>
6060
<groupId>org.support-project</groupId>
6161
<artifactId>common</artifactId>
62-
<version>1.4.0</version>
62+
<version>1.5.0</version>
6363
</dependency>
6464

6565
<dependency>

src/main/java/org/support/project/web/dao/UsersDao.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,18 @@ public void truncate() {
197197
String sql = SQLManager.getInstance().getSql("/org/support/project/web/dao/sql/UsersDao/UsersDao_truncate.sql");
198198
executeUpdate(sql);
199199
}
200+
201+
/**
202+
* メールアドレスで検索
203+
* (Ldapログイン時は、USER_KEYはIDになるので注意)
204+
* @param mail メールアドレス
205+
* @return ユーザ情報
206+
*/
207+
public UsersEntity selectOnMail(String mail) {
208+
if (mail == null) {
209+
return null;
210+
}
211+
String sql = "SELECT * FROM USERS WHERE LOWER(MAIL_ADDRESS) = ?;";
212+
return executeQuerySingle(sql, UsersEntity.class, mail.toLowerCase());
213+
}
200214
}

src/main/java/org/support/project/web/logic/SanitizingLogic.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public static SanitizingLogic get() {
5454
private static final Pattern HTML_CLASS = Pattern.compile("[a-zA-Z0-9\\s,\\-_]+");
5555
private static final Pattern ONSITE_URL = Pattern.compile("(?:[\\p{L}\\p{N}\\\\\\.\\#@\\$%\\+&;\\-_~,\\?=/!]+|\\#(\\w)+)");
5656
private static final Pattern OFFSITE_URL = Pattern
57-
.compile("\\s*(?:(?:ht|f)tps?://|mailto:)[\\p{L}\\p{N}]" + "[\\p{L}\\p{N}\\p{Zs}\\.\\#@\\$%\\+&;:\\-_~,\\?=/!\\(\\)]*+\\s*");
57+
.compile("\\s*(?:(?:ht|f)tps?://|file://|smb://|\\\\\\\\|mailto:)[\\p{L}\\p{N}]"
58+
+ "[\\p{L}\\p{N}\\p{Zs}\\.\\#@\\$%\\+&;:\\-_~,\\?=/!\\(\\)]*+\\s*");
5859
private static final Pattern NUMBER = Pattern.compile("[+-]?(?:(?:[0-9]+(?:\\.[0-9]*)?)|\\.[0-9]+)");
5960
private static final Pattern NAME = Pattern.compile("[a-zA-Z0-9\\-_\\$]+");
6061
private static final Pattern ALIGN = Pattern.compile("(?i)center|left|right|justify|char");
@@ -66,7 +67,11 @@ public boolean apply(String s) {
6667
};
6768
private static final Predicate<String> ONSITE_OR_OFFSITE_URL = new Predicate<String>() {
6869
public boolean apply(String s) {
69-
return ONSITE_URL.matcher(s).matches() || OFFSITE_URL.matcher(s).matches();
70+
boolean result = ONSITE_URL.matcher(s).matches() || OFFSITE_URL.matcher(s).matches();
71+
if (LOG.isDebugEnabled()) {
72+
LOG.debug("[ONSITE_OR_OFFSITE_URL]: " + result + "\t" + s);
73+
}
74+
return result;
7075
}
7176
};
7277
private static final Pattern HISTORY_BACK = Pattern.compile("(?:javascript:)?\\Qhistory.go(-1)\\E");
@@ -76,7 +81,10 @@ public boolean apply(String s) {
7681
.allowAttributes("title").matching(HTML_TITLE).globally().allowStyling().allowAttributes("align").matching(ALIGN).onElements("p")
7782
.allowAttributes("for").matching(HTML_ID).onElements("label").allowAttributes("color").matching(COLOR_NAME_OR_COLOR_CODE)
7883
.onElements("font").allowAttributes("face").matching(Pattern.compile("[\\w;, \\-]+")).onElements("font").allowAttributes("size")
79-
.matching(NUMBER).onElements("font").allowAttributes("href").matching(ONSITE_OR_OFFSITE_URL).onElements("a").allowStandardUrlProtocols()
84+
.matching(NUMBER).onElements("font")
85+
.allowAttributes("href").matching(ONSITE_OR_OFFSITE_URL).onElements("a")
86+
// .allowStandardUrlProtocols()
87+
.allowUrlProtocols("http", "https", "mailto", "file", "smb", "\\\\")
8088
.allowAttributes("target")
8189
// .onElements("a")
8290
// .allowAttributes("name")

src/test/java/org/support/project/web/logic/SanitizingLogicTest.java

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,59 @@ public void testSanitize()
6666
throw e;
6767
}
6868
}
69-
69+
70+
@Test
71+
@Order(order = 2)
72+
public void testUNC() throws Exception {
73+
LOG.info("testUNC");
74+
String base = "<p><a href=\"\\\\hoge\\data\" title=\"UNCPathLink\">UNCPathLink</a></p>";
75+
String result = SanitizingLogic.get().sanitize(base);
76+
try {
77+
String check = "<p><a href=\"\\\\hoge\\data\" title=\"UNCPathLink\" rel=\"nofollow\">UNCPathLink</a></p>";
78+
org.junit.Assert.assertEquals(check, result);
79+
} catch (AssertionError e) {
80+
LOG.info("Sanitize");
81+
LOG.info("[Base] : " + base);
82+
LOG.info("[Result] : " + result);
83+
throw e;
84+
}
85+
}
86+
87+
@Test
88+
@Order(order = 3)
89+
public void testFile() throws Exception {
90+
LOG.info("testFile");
91+
String base = "<p><a href=\"file://hoge/data\" title=\"UNCPathLink\">UNCPathLink</a></p>";
92+
String result = SanitizingLogic.get().sanitize(base);
93+
try {
94+
String check = "<p><a href=\"file://hoge/data\" title=\"UNCPathLink\" rel=\"nofollow\">UNCPathLink</a></p>";
95+
org.junit.Assert.assertEquals(check, result);
96+
} catch (AssertionError e) {
97+
LOG.info("Sanitize");
98+
LOG.info("[Base] : " + base);
99+
LOG.info("[Result] : " + result);
100+
throw e;
101+
}
102+
}
103+
104+
@Test
105+
@Order(order = 4)
106+
public void testSamba() throws Exception {
107+
LOG.info("testSamba");
108+
String base = "<p><a href=\"smb://hoge/data\" title=\"UNCPathLink\">UNCPathLink</a></p>";
109+
String result = SanitizingLogic.get().sanitize(base);
110+
try {
111+
String check = "<p><a href=\"smb://hoge/data\" title=\"UNCPathLink\" rel=\"nofollow\">UNCPathLink</a></p>";
112+
org.junit.Assert.assertEquals(check, result);
113+
} catch (AssertionError e) {
114+
LOG.info("Sanitize");
115+
LOG.info("[Base] : " + base);
116+
LOG.info("[Result] : " + result);
117+
throw e;
118+
}
119+
}
120+
121+
122+
123+
70124
}

0 commit comments

Comments
 (0)