From ba4610155f9ee5ff40b2c824a4f276ce7b3f1ad3 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 6 Sep 2023 16:34:39 +1000 Subject: [PATCH] Fix #3705. Fix ambiguity in using commas in unquoted strings in facet selector. --- src/ifcopenshell-python/ifcopenshell/util/selector.py | 2 +- src/ifcopenshell-python/test/util/test_selector.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index e88dfac47b..b0c2b2fb7e 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -51,7 +51,7 @@ filter_elements_grammar = lark.Lark( ifc_class: /Ifc\\w+/ value: special | quoted_string | regex_string | unquoted_string - unquoted_string: /[^.=\\s]+/ + unquoted_string: /[^,.=\\s]+/ regex_string: "/" /[^\\/]+/ "/" quoted_string: ESCAPED_STRING diff --git a/src/ifcopenshell-python/test/util/test_selector.py b/src/ifcopenshell-python/test/util/test_selector.py index a63a8fdfb2..ebb2528f15 100644 --- a/src/ifcopenshell-python/test/util/test_selector.py +++ b/src/ifcopenshell-python/test/util/test_selector.py @@ -147,6 +147,9 @@ class TestFilterElements(test.bootstrap.IFC4): assert subject.filter_elements(self.file, 'IfcWall, Name="Foo\'s \\"quoted\\" name..."') == {element} assert subject.filter_elements(self.file, "IfcWall, Name=/Fo.*/") == {element} assert subject.filter_elements(self.file, "IfcWall, Description=NULL") == {element, element2} + element.Name = "Foo" + element.Description = "Foobar" + assert subject.filter_elements(self.file, "IfcWall, Name=Foo, Description=Foobar") == {element} def test_selecting_by_type(self): element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")