Skip to content

Commit bb3d1d2

Browse files
authored
Update UserMgmtService.java
valid email&username to fix an XSS vulnerability
1 parent c242138 commit bb3d1d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/org/b3log/solo/service/UserMgmtService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ public String addUser(final JSONObject requestJSONObject) throws ServiceExceptio
274274
try {
275275
final JSONObject user = new JSONObject();
276276
final String userEmail = requestJSONObject.optString(User.USER_EMAIL).trim().toLowerCase();
277+
if (!Strings.isEmail(userEmail)) {
278+
throw new ServiceException(langPropsService.get("mailInvalidLabel"));
279+
}
277280
final JSONObject duplicatedUser = userRepository.getByEmail(userEmail);
278281

279282
if (null != duplicatedUser) {
@@ -287,6 +290,9 @@ public String addUser(final JSONObject requestJSONObject) throws ServiceExceptio
287290
user.put(User.USER_EMAIL, userEmail);
288291

289292
final String userName = requestJSONObject.optString(User.USER_NAME);
293+
if (UserExt.invalidUserName(userName)) {
294+
throw new ServiceException(langPropsService.get("userNameInvalidLabel"));
295+
}
290296
user.put(User.USER_NAME, userName);
291297

292298
final String userPassword = requestJSONObject.optString(User.USER_PASSWORD);

0 commit comments

Comments
 (0)