[PATCH] Fix directory path validation for 'DIR' type storage pool

The current regex will refuse the strings which end with '/'. Obviously, even if the dir path ends with '/', it's still valid. So this patch changes the regex to accept this case. Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index ac97e1a..8c0025f 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -167,7 +167,7 @@ kimchi.validateDirForm = function () { kimchi.message.error.code('KCHPOOL6002E'); return false; } - if (!/((\/([0-9a-zA-Z-_\.]+)))$/.test(path)) { + if (!/(\/([0-9a-zA-Z-_\.]+))+\/?$/.test(path)) { kimchi.message.error.code('KCHAPI6003E'); return false; } -- 1.8.4.2

Reviewed-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> On 02/21/2014 05:15 PM, Mark Wu wrote:
The current regex will refuse the strings which end with '/'. Obviously, even if the dir path ends with '/', it's still valid. So this patch changes the regex to accept this case.
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index ac97e1a..8c0025f 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -167,7 +167,7 @@ kimchi.validateDirForm = function () { kimchi.message.error.code('KCHPOOL6002E'); return false; } - if (!/((\/([0-9a-zA-Z-_\.]+)))$/.test(path)) { + if (!/(\/([0-9a-zA-Z-_\.]+))+\/?$/.test(path)) { kimchi.message.error.code('KCHAPI6003E'); return false; }
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

于 2014/2/21 17:15, Mark Wu 写道:
The current regex will refuse the strings which end with '/'. Obviously, even if the dir path ends with '/', it's still valid. So this patch changes the regex to accept this case.
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index ac97e1a..8c0025f 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -167,7 +167,7 @@ kimchi.validateDirForm = function () { kimchi.message.error.code('KCHPOOL6002E'); return false; } - if (!/((\/([0-9a-zA-Z-_\.]+)))$/.test(path)) { + if (!/(\/([0-9a-zA-Z-_\.]+))+\/?$/.test(path)) { I think "/foo1/dev///" is also a legal path.
kimchi.message.error.code('KCHAPI6003E'); return false; }

On 02/21/2014 06:15 AM, Mark Wu wrote:
The current regex will refuse the strings which end with '/'. Obviously, even if the dir path ends with '/', it's still valid. So this patch changes the regex to accept this case.
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index ac97e1a..8c0025f 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -167,7 +167,7 @@ kimchi.validateDirForm = function () { kimchi.message.error.code('KCHPOOL6002E'); return false; } - if (!/((\/([0-9a-zA-Z-_\.]+)))$/.test(path)) { + if (!/(\/([0-9a-zA-Z-_\.]+))+\/?$/.test(path)) {
This verification is restricting so much the user. I can have any valid path in my system. /aline manera/ /crístian / /阿莲 This verification should be done in backend. For UI, we should only check if the string starts with /
kimchi.message.error.code('KCHAPI6003E'); return false; }

I agree. Am 21-02-2014 10:55, schrieb Aline Manera:
+ if (!/(\/([0-9a-zA-Z-_\.]+))+\/?$/.test(path)) {
This verification is restricting so much the user. I can have any valid path in my system.
/aline manera/ /crístian / /阿莲
This verification should be done in backend. For UI, we should only check if the string starts with /
participants (5)
-
Aline Manera
-
Crístian Viana
-
Mark Wu
-
Sheldon
-
Shu Ming