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>
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";
}
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;
}