From 894c5b2d19707116d89654043613a80993e3ec97 Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 28 Mar 2017 10:31:40 +0800 Subject: [PATCH 1/2] max length checking for project name and description --- .../topcoder/service/project/impl/ProjectServiceBean.java | 6 ++++-- src/web/scripts/common.js | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java b/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java index c28ec8cc6..b22ae3280 100644 --- a/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java +++ b/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java @@ -1996,13 +1996,15 @@ private void checkProjectData(ProjectData projectData, boolean isCreate) throws throw logException(new IllegalArgumentFault("The name attribute of the project data can not be null.")); } else if (name.trim().length() == 0) { throw logException(new IllegalArgumentFault("The name attribute of the project data can not be empty.")); + } else if (name.trim().length() > 200) { + throw logException(new IllegalArgumentFault("The name attribute of the project data cannot be more than 200 characters.")); } String description = projectData.getDescription(); if (null == description) { throw logException(new IllegalArgumentFault("The description attribute of the project data can not be null.")); - } else if (description.trim().length() == 0) { - throw logException(new IllegalArgumentFault("The description attribute of the project data can not be empty.")); + } else if (description.trim().length() > 10000) { + throw logException(new IllegalArgumentFault("The description attribute of the project data cann't be more than 10000 characters.")); } //added in version 2.2 diff --git a/src/web/scripts/common.js b/src/web/scripts/common.js index 8c5247d83..8142e9f2e 100644 --- a/src/web/scripts/common.js +++ b/src/web/scripts/common.js @@ -112,11 +112,9 @@ $(document).ready(function() { $("#swFileDescription, #fileDescription, #fileDescription2").bind('keydown keyup paste', limitFileDescriptionChars(200)); - $("#newProjectDescription").bind('keydown keyup paste', limitFileDescriptionChars(2000)); + $("#newProjectDescription").bind('keydown keyup paste', limitFileDescriptionChars(10000)); }); -var invalidCharsRegExp = /[^a-zA-Z0-9\$!\(\)\[\]\'\"\-\.\,\/\+ ]+/mg; - var DEFAULT_TIMEZONE = "America/New_York"; /** From 3f130843ae9d7c52edc514dc86c43106480645c5 Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 28 Mar 2017 10:34:43 +0800 Subject: [PATCH 2/2] ignore null case --- .../com/topcoder/service/project/impl/ProjectServiceBean.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java b/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java index b22ae3280..89613cd97 100644 --- a/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java +++ b/services/project_service/src/java/main/com/topcoder/service/project/impl/ProjectServiceBean.java @@ -2001,9 +2001,7 @@ private void checkProjectData(ProjectData projectData, boolean isCreate) throws } String description = projectData.getDescription(); - if (null == description) { - throw logException(new IllegalArgumentFault("The description attribute of the project data can not be null.")); - } else if (description.trim().length() > 10000) { + if (null != description && description.trim().length() > 10000) { throw logException(new IllegalArgumentFault("The description attribute of the project data cann't be more than 10000 characters.")); }