Resolved JIRA issues IOT-871 and IOT-892.
authorG S Senthil Kumar <senthil.gs@samsung.com>
Wed, 23 Dec 2015 07:30:15 +0000 (13:00 +0530)
committerUze Choi <uzchoi@samsung.com>
Mon, 28 Dec 2015 01:31:31 +0000 (01:31 +0000)
Both issues are related to invalid resource URI.
Included code in ServiceProvider plug-in to handle invalid characters and patterns in Resource URI.
Code indented and formatted.

Change-Id: I6efd8ed6d9b098e4f2c60535c353ece17b92866f
Signed-off-by: G S Senthil Kumar <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4713
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Radha Bhavani <radha.p@samsung.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Constants.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java

index 2d59eb9..cd4c52a 100644 (file)
@@ -159,7 +159,11 @@ public class Constants {
     public static final String         SIMPLE_RESOURCE_OTHER_DETAILS_PAGE_MESSAGE = "Fill other details of the resource";
 
     public static final String         SINGLE_RESOURCE                            = "Single Resource";
-    public static final String         INVALID_URI_MESSAGE                        = "Resource URI should start with a '/' followed by atleast one character and it should not contain either # or ? or % or consecutive '/'.";
+    public static final String         INVALID_URI_MESSAGE                        = "Resource URI should start with a '/'."
+                                                                                          + "\nIt should be 2 to 63 chars long.\n"
+                                                                                          + "It should not contain # or ? or % or "
+                                                                                          + "consecutive '/' or '/./' or "
+                                                                                          + "'/..'(more than one dot following a slash).";
     public static final int            TREE_EXPANSION_LEVEL                       = 10;
 
     public static final String         BASELINE_INTERFACE                         = "oic.if.baseline";
index 23be6db..1b3195f 100644 (file)
@@ -512,8 +512,10 @@ public class Utility {
     }
 
     public static boolean isUriValid(String resURI) {
-        if (null == resURI || resURI.length() < 2 || !resURI.startsWith("/")
-                || resURI.contains("//") || resURI.contains("?")
+        if (null == resURI || resURI.length() < 2 || resURI.length() > 63
+                || !resURI.startsWith("/") || resURI.endsWith("/")
+                || resURI.contains("/..") || resURI.contains("//")
+                || resURI.contains("/./") || resURI.contains("?")
                 || resURI.contains("#") || resURI.contains("%")) {
             return false;
         }