From 3d1dc66f6dab3dd5946beb8b0822fdc677153697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Thu, 8 Apr 2010 16:06:54 +0000 Subject: [PATCH] - improve matching form_id with url by using regular expression git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34405 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/Tool/SelectionTool.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/product/ERP5Form/Tool/SelectionTool.py b/product/ERP5Form/Tool/SelectionTool.py index ea9ced3be8..bf42737fe2 100644 --- a/product/ERP5Form/Tool/SelectionTool.py +++ b/product/ERP5Form/Tool/SelectionTool.py @@ -595,10 +595,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): # XXX-Luke: As this is not possible to do form_id -> action_id the # only way to know if form_id is implemented by action of document # is to use string matching. - # Current matching is not perfect - if action url is defined like: - # bla/bla/[form_id]?q - # it will not match. re hacker will be able to improve - if url.endswith(form_id): + # This re will (form_id = Base_view): + # qdsqdsq/Base_view --> match + # qdsqdsq/Base_view?qsdsqd --> matches + # qdsqdsq/Base_view/qsdsqd --> matches + # qdsqdsq/Base_viewAaa --> doesn't match + # qdsqdsq/Umpa_view --> doesn't match + if re.search('/%s($|\W+)' % form_id, url): return form_id return 'view' -- 2.30.9