From 3c3b6e8cc089f6ec13f196d73c39768a9e0dc33a Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 28 Aug 2018 11:02:42 +0200 Subject: [PATCH 01/11] check that parameters are string before applying regex match --- conans/model/ref.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/conans/model/ref.py b/conans/model/ref.py index dd99986bd47..877907c11ff 100644 --- a/conans/model/ref.py +++ b/conans/model/ref.py @@ -4,11 +4,23 @@ from conans.model.version import Version +# TODO: Move to some tools module +# TODO: Use Conan way to skip coverage for py2/3 version +try: # pragma: no py3 cover + basestring # attempt to evaluate basestring + + def isstr(s): + return isinstance(s, basestring) +except NameError: # pragma: no py2 cover + def isstr(s): + return isinstance(s, (str, bytes)) + + class ConanName(object): _max_chars = 50 _min_chars = 2 _validation_pattern = re.compile("^[a-zA-Z0-9_][a-zA-Z0-9_\+\.-]{%s,%s}$" - % (_min_chars - 1, _max_chars)) + % (_min_chars - 1, _max_chars - 1)) @staticmethod def invalid_name_message(name): @@ -20,23 +32,33 @@ def invalid_name_message(name): % (name, ConanName._min_chars)) else: message = ("'%s' is an invalid name. Valid names MUST begin with a " - "letter or number, have between %s-%s chars, including " + "letter, number or underscore, have between %s-%s chars, including " "letters, numbers, underscore, dot and dash" % (name, ConanName._min_chars, ConanName._max_chars)) raise InvalidNameException(message) + @staticmethod + def validate_string(value, message=None): + """Check for string""" + if not isstr(value): + message = message or "'{value}' {reason}" + raise InvalidNameException(message.format(value=value, reason="is not an string")) + @staticmethod def validate_user(username): + ConanName.validate_string(username) if ConanName._validation_pattern.match(username) is None: ConanName.invalid_name_message(username) @staticmethod def validate_name(name, version=False): """Check for name compliance with pattern rules""" + ConanName.validate_string(name) if name == "*": return if ConanName._validation_pattern.match(name) is None: if version and name.startswith("[") and name.endswith("]"): + # TODO: Check value between brackets return ConanName.invalid_name_message(name) From 161e1f25c2d99c04c9ac1c85c82764e05262eb6e Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 28 Aug 2018 11:03:06 +0200 Subject: [PATCH 02/11] add tests related to ConanName --- conans/test/model/ref_test.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/conans/test/model/ref_test.py b/conans/test/model/ref_test.py index c74bdd3b259..403480204ed 100644 --- a/conans/test/model/ref_test.py +++ b/conans/test/model/ref_test.py @@ -1,5 +1,5 @@ import unittest -from conans.model.ref import ConanFileReference +from conans.model.ref import ConanFileReference, ConanName, InvalidNameException from conans.errors import ConanException @@ -42,3 +42,27 @@ def errors_test(self): "opencv/2.4.10@laso%s/testing" % "A" * 40) self.assertRaises(ConanException, ConanFileReference.loads, "opencv/2.4.10@laso/testing%s" % "A" * 40) + + +class ConanNameTestCase(unittest.TestCase): + def validate_name_test(self): + self.assertIsNone(ConanName.validate_name("string.dot.under-score.123")) + self.assertIsNone(ConanName.validate_name("_underscore+123")) + self.assertIsNone(ConanName.validate_name("*")) + self.assertIsNone(ConanName.validate_name("a" * ConanName._min_chars)) + self.assertIsNone(ConanName.validate_name("a" * ConanName._max_chars)) + + def validate_name_test_invalid(self): + self.assertRaises(InvalidNameException, ConanName.validate_name, "-no.dash.start") + self.assertRaises(InvalidNameException, ConanName.validate_name, "a" * (ConanName._min_chars - 1)) + self.assertRaises(InvalidNameException, ConanName.validate_name, "a" * (ConanName._max_chars + 1)) + # Invalid types + self.assertRaises(InvalidNameException, ConanName.validate_name, 123.34) + self.assertRaises(InvalidNameException, ConanName.validate_name, ("item1", "item2",)) + + def validate_name_version_test(self): + self.assertIsNone(ConanName.validate_name("[vvvv]", version=True)) + + def validate_name_version_test_invalid(self): + self.assertRaises(InvalidNameException, ConanName.validate_name, "[no.close.bracket", True) + self.assertRaises(InvalidNameException, ConanName.validate_name, "no.open.bracket]", True) From f3d6f33a7d4382aa276e26b0f21fe134410ef11a Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 28 Aug 2018 11:03:18 +0200 Subject: [PATCH 03/11] typo --- conans/util/config_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/util/config_parser.py b/conans/util/config_parser.py index 64404a0f4fb..6c2d62e9452 100644 --- a/conans/util/config_parser.py +++ b/conans/util/config_parser.py @@ -4,7 +4,7 @@ def get_bool_from_text_value(value): """ to be deprecated - It has issues, as accepting into the registry whatever=value, as False, withoug + It has issues, as accepting into the registry whatever=value, as False, without complaining """ return (value == "1" or value.lower() == "yes" or value.lower() == "y" or From 813344687564487eab1297b6d8e1cdad0c31aecc Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 28 Aug 2018 11:06:16 +0200 Subject: [PATCH 04/11] update docs related to function --- conans/model/ref.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conans/model/ref.py b/conans/model/ref.py index 877907c11ff..f706692edf8 100644 --- a/conans/model/ref.py +++ b/conans/model/ref.py @@ -74,7 +74,10 @@ class ConanFileReference(namedtuple("ConanFileReference", "name version user cha def __new__(cls, name, version, user, channel, revision=None): """Simple name creation. @param name: string containing the desired name - @param validate: checks for valid complex name. default True + @param version: string containing the desired version + @param user: string containing the user name + @param channel: string containing the user channel + @param revision: string containing the revision (optional) """ ConanName.validate_name(name) ConanName.validate_name(version, True) From 9f48b5de4538328f413b7b4a993694288bddbae1 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 28 Aug 2018 11:56:53 +0200 Subject: [PATCH 05/11] use six to check for string types --- conans/model/ref.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/conans/model/ref.py b/conans/model/ref.py index f706692edf8..d7d2359d740 100644 --- a/conans/model/ref.py +++ b/conans/model/ref.py @@ -1,21 +1,10 @@ from collections import namedtuple import re +from six import string_types from conans.errors import ConanException, InvalidNameException from conans.model.version import Version -# TODO: Move to some tools module -# TODO: Use Conan way to skip coverage for py2/3 version -try: # pragma: no py3 cover - basestring # attempt to evaluate basestring - - def isstr(s): - return isinstance(s, basestring) -except NameError: # pragma: no py2 cover - def isstr(s): - return isinstance(s, (str, bytes)) - - class ConanName(object): _max_chars = 50 _min_chars = 2 @@ -40,7 +29,7 @@ def invalid_name_message(name): @staticmethod def validate_string(value, message=None): """Check for string""" - if not isstr(value): + if not isinstance(value, string_types): message = message or "'{value}' {reason}" raise InvalidNameException(message.format(value=value, reason="is not an string")) From c933ec006122492d516260a4896c81a13721820c Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Wed, 29 Aug 2018 11:17:59 +0200 Subject: [PATCH 06/11] use a custom message to validate each field --- conans/model/ref.py | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/conans/model/ref.py b/conans/model/ref.py index d7d2359d740..7ee749b6040 100644 --- a/conans/model/ref.py +++ b/conans/model/ref.py @@ -12,44 +12,47 @@ class ConanName(object): % (_min_chars - 1, _max_chars - 1)) @staticmethod - def invalid_name_message(name): - if len(name) > ConanName._max_chars: - message = ("'%s' is too long. Valid names must contain at most %s characters." - % (name, ConanName._max_chars)) - elif len(name) < ConanName._min_chars: - message = ("'%s' is too short. Valid names must contain at least %s characters." - % (name, ConanName._min_chars)) + def invalid_name_message(value, message=None): + message = message or "'{value}' {reason}" + if len(value) > ConanName._max_chars: + reason = "is too long. Valid names must contain at most %s characters."\ + % ConanName._max_chars + elif len(value) < ConanName._min_chars: + reason = "is too short. Valid names must contain at least %s characters."\ + % ConanName._min_chars else: - message = ("'%s' is an invalid name. Valid names MUST begin with a " - "letter, number or underscore, have between %s-%s chars, including " - "letters, numbers, underscore, dot and dash" - % (name, ConanName._min_chars, ConanName._max_chars)) - raise InvalidNameException(message) + reason = ("is an invalid name. Valid names MUST begin with a " + "letter, number or underscore, have between %s-%s chars, including " + "letters, numbers, underscore, dot and dash" + % (ConanName._min_chars, ConanName._max_chars)) + raise InvalidNameException(message.format(value=value, reason=reason, + type=type(value).__name__)) @staticmethod def validate_string(value, message=None): """Check for string""" if not isinstance(value, string_types): - message = message or "'{value}' {reason}" - raise InvalidNameException(message.format(value=value, reason="is not an string")) + message = message or "'{value}' (type {type}) {reason}" + raise InvalidNameException(message.format(value=value, reason="is not a string", + type=type(value).__name__)) @staticmethod - def validate_user(username): - ConanName.validate_string(username) + def validate_user(username, message=None): + ConanName.validate_string(username, message=message) if ConanName._validation_pattern.match(username) is None: - ConanName.invalid_name_message(username) + ConanName.invalid_name_message(username, message=message) @staticmethod - def validate_name(name, version=False): + def validate_name(name, version=False, message=None): """Check for name compliance with pattern rules""" - ConanName.validate_string(name) + ConanName.validate_string(name, message=message) if name == "*": return if ConanName._validation_pattern.match(name) is None: if version and name.startswith("[") and name.endswith("]"): # TODO: Check value between brackets return - ConanName.invalid_name_message(name) + ConanName.invalid_name_message(name, message=message) class ConanFileReference(namedtuple("ConanFileReference", "name version user channel")): @@ -68,14 +71,15 @@ def __new__(cls, name, version, user, channel, revision=None): @param channel: string containing the user channel @param revision: string containing the revision (optional) """ - ConanName.validate_name(name) - ConanName.validate_name(version, True) - ConanName.validate_name(user) - ConanName.validate_name(channel) + message = "Value provided for {item}, '{{value}}' (type {{type}}), {{reason}}" + ConanName.validate_name(name, message=message.format(item="package name")) + ConanName.validate_name(version, True, message=message.format(item="package version")) + ConanName.validate_name(user, message=message.format(item="package user name")) + ConanName.validate_name(channel, message=message.format(item="package user")) version = Version(version) obj = super(cls, ConanFileReference).__new__(cls, name, version, user, channel) if revision: - ConanName.validate_name(revision) + ConanName.validate_name(revision, message=message.format(item="package revision")) obj.revision = revision return obj @@ -137,7 +141,8 @@ def __new__(cls, conan, package_id): revision = None if "#" in package_id: package_id, revision = package_id.rsplit("#", 1) - ConanName.validate_name(revision) + message = "Value provided for package revision, '{value}' (type {type}) {reason}" + ConanName.validate_name(revision, message=message) obj = super(cls, PackageReference).__new__(cls, conan, package_id) obj.revision = revision return obj From 46df758d2a7fc31fd20a2cfc7f20e35a77a0dd11 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Wed, 29 Aug 2018 11:18:14 +0200 Subject: [PATCH 07/11] refactor tests to validate custom messages --- conans/test/model/ref_test.py | 46 ++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/conans/test/model/ref_test.py b/conans/test/model/ref_test.py index 403480204ed..bdf54cb587e 100644 --- a/conans/test/model/ref_test.py +++ b/conans/test/model/ref_test.py @@ -45,6 +45,15 @@ def errors_test(self): class ConanNameTestCase(unittest.TestCase): + + def _check_invalid_format(self, value, *args): + with self.assertRaisesRegexp(InvalidNameException, "Valid names"): + ConanName.validate_name(value, *args) + + def _check_invalid_type(self, value): + with self.assertRaisesRegexp(InvalidNameException, "is not a string"): + ConanName.validate_name(value) + def validate_name_test(self): self.assertIsNone(ConanName.validate_name("string.dot.under-score.123")) self.assertIsNone(ConanName.validate_name("_underscore+123")) @@ -52,17 +61,36 @@ def validate_name_test(self): self.assertIsNone(ConanName.validate_name("a" * ConanName._min_chars)) self.assertIsNone(ConanName.validate_name("a" * ConanName._max_chars)) - def validate_name_test_invalid(self): - self.assertRaises(InvalidNameException, ConanName.validate_name, "-no.dash.start") - self.assertRaises(InvalidNameException, ConanName.validate_name, "a" * (ConanName._min_chars - 1)) - self.assertRaises(InvalidNameException, ConanName.validate_name, "a" * (ConanName._max_chars + 1)) - # Invalid types - self.assertRaises(InvalidNameException, ConanName.validate_name, 123.34) - self.assertRaises(InvalidNameException, ConanName.validate_name, ("item1", "item2",)) + def validate_name_test_invalid_format(self): + self._check_invalid_format("-no.dash.start") + self._check_invalid_format("a" * (ConanName._min_chars - 1)) + self._check_invalid_format("a" * (ConanName._max_chars + 1)) + + def validate_name_test_invalid_type(self): + self._check_invalid_type(123.34) + self._check_invalid_type(("item1", "item2",)) def validate_name_version_test(self): self.assertIsNone(ConanName.validate_name("[vvvv]", version=True)) def validate_name_version_test_invalid(self): - self.assertRaises(InvalidNameException, ConanName.validate_name, "[no.close.bracket", True) - self.assertRaises(InvalidNameException, ConanName.validate_name, "no.open.bracket]", True) + self._check_invalid_format("[no.close.bracket", True) + self._check_invalid_format("no.open.bracket]", True) + + def custom_message_test_invalid_type(self): + message = "value={value}, type={type}, reason={reason}" + value = 1234 + typename = type(value).__name__ + reason = "is not a string" + with self.assertRaisesRegexp(InvalidNameException, + message.format(value=value, type=typename, reason=reason)): + ConanName.validate_name(value, message=message) + + def custom_message_test_invalid_format(self): + message = "value={value}, type={type}, reason={reason}" + value = "-no.dash.start" + typename = type(value).__name__ + reason = "is an invalid name" # Message is longer, but it will validate. + with self.assertRaisesRegexp(InvalidNameException, + message.format(value=value, type=typename, reason=reason)): + ConanName.validate_name(value, message=message) From d16c6da80c20e2e8a8c3684e828a947e73b5149f Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Wed, 29 Aug 2018 12:04:33 +0200 Subject: [PATCH 08/11] fix tests: message is more explicit --- conans/test/command/new_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conans/test/command/new_test.py b/conans/test/command/new_test.py index 5f9410bdec4..558e352ac2d 100644 --- a/conans/test/command/new_test.py +++ b/conans/test/command/new_test.py @@ -28,12 +28,12 @@ def new_error_test(self): client = TestClient() error = client.run('new A/1.3@myuser/testing', ignore_error=True) self.assertTrue(error) - self.assertIn("ERROR: 'A' is too short. Valid names must contain at least 2 characters.", - client.user_io.out) + self.assertIn("ERROR: Value provided for package name, 'A' (type str), is too short. Valid " + "names must contain at least 2 characters.", client.user_io.out) error = client.run('new A2/1.3@myuser/u', ignore_error=True) self.assertTrue(error) - self.assertIn("ERROR: 'u' is too short. Valid names must contain at least 2 characters.", - client.user_io.out) + self.assertIn("ERROR: Value provided for package user, 'u' (type str), is too short. Valid " + "names must contain at least 2 characters.", client.user_io.out) def new_dash_test(self): """ packages with dash From 7dc4321c399b1eb3260fbefae5823b4d7eab9642 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 4 Sep 2018 17:14:48 +0200 Subject: [PATCH 09/11] given #3464 this is dead code --- conans/model/ref.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/conans/model/ref.py b/conans/model/ref.py index 7ee749b6040..ac043cbf415 100644 --- a/conans/model/ref.py +++ b/conans/model/ref.py @@ -36,12 +36,6 @@ def validate_string(value, message=None): raise InvalidNameException(message.format(value=value, reason="is not a string", type=type(value).__name__)) - @staticmethod - def validate_user(username, message=None): - ConanName.validate_string(username, message=message) - if ConanName._validation_pattern.match(username) is None: - ConanName.invalid_name_message(username, message=message) - @staticmethod def validate_name(name, version=False, message=None): """Check for name compliance with pattern rules""" From 672b4604c7a4b079bc899d89d919e45a9c6a87c4 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Wed, 5 Sep 2018 09:43:58 +0200 Subject: [PATCH 10/11] format error message only if we are actually going to use it --- conans/model/ref.py | 41 ++++++++++++++++++--------------- conans/test/command/new_test.py | 2 +- conans/test/model/ref_test.py | 18 --------------- 3 files changed, 23 insertions(+), 38 deletions(-) diff --git a/conans/model/ref.py b/conans/model/ref.py index ac043cbf415..494b50a8142 100644 --- a/conans/model/ref.py +++ b/conans/model/ref.py @@ -12,8 +12,7 @@ class ConanName(object): % (_min_chars - 1, _max_chars - 1)) @staticmethod - def invalid_name_message(value, message=None): - message = message or "'{value}' {reason}" + def invalid_name_message(value, reference_token=None): if len(value) > ConanName._max_chars: reason = "is too long. Valid names must contain at most %s characters."\ % ConanName._max_chars @@ -25,28 +24,34 @@ def invalid_name_message(value, message=None): "letter, number or underscore, have between %s-%s chars, including " "letters, numbers, underscore, dot and dash" % (ConanName._min_chars, ConanName._max_chars)) - raise InvalidNameException(message.format(value=value, reason=reason, - type=type(value).__name__)) + message = "Value provided{ref_token}, '{value}' (type {type}), {reason}".format( + ref_token=" for {}".format(reference_token) if reference_token else "", + value=value, type=type(value).__name__, reason=reason + ) + raise InvalidNameException(message) @staticmethod - def validate_string(value, message=None): + def validate_string(value, reference_token=None): """Check for string""" if not isinstance(value, string_types): - message = message or "'{value}' (type {type}) {reason}" - raise InvalidNameException(message.format(value=value, reason="is not a string", - type=type(value).__name__)) + message = "Value provided{ref_token}, '{value}' (type {type}), {reason}".format( + ref_token=" for {}".format(reference_token) if reference_token else "", + value=value, type=type(value).__name__, + reason="is not a string" + ) + raise InvalidNameException(message) @staticmethod - def validate_name(name, version=False, message=None): + def validate_name(name, version=False, reference_token=None): """Check for name compliance with pattern rules""" - ConanName.validate_string(name, message=message) + ConanName.validate_string(name, reference_token=reference_token) if name == "*": return if ConanName._validation_pattern.match(name) is None: if version and name.startswith("[") and name.endswith("]"): # TODO: Check value between brackets return - ConanName.invalid_name_message(name, message=message) + ConanName.invalid_name_message(name, reference_token=reference_token) class ConanFileReference(namedtuple("ConanFileReference", "name version user channel")): @@ -65,15 +70,14 @@ def __new__(cls, name, version, user, channel, revision=None): @param channel: string containing the user channel @param revision: string containing the revision (optional) """ - message = "Value provided for {item}, '{{value}}' (type {{type}}), {{reason}}" - ConanName.validate_name(name, message=message.format(item="package name")) - ConanName.validate_name(version, True, message=message.format(item="package version")) - ConanName.validate_name(user, message=message.format(item="package user name")) - ConanName.validate_name(channel, message=message.format(item="package user")) + ConanName.validate_name(name, reference_token="package name") + ConanName.validate_name(version, True, reference_token="package version") + ConanName.validate_name(user, reference_token="user name") + ConanName.validate_name(channel, reference_token="channel") version = Version(version) obj = super(cls, ConanFileReference).__new__(cls, name, version, user, channel) if revision: - ConanName.validate_name(revision, message=message.format(item="package revision")) + ConanName.validate_name(revision, reference_token="revision") obj.revision = revision return obj @@ -135,8 +139,7 @@ def __new__(cls, conan, package_id): revision = None if "#" in package_id: package_id, revision = package_id.rsplit("#", 1) - message = "Value provided for package revision, '{value}' (type {type}) {reason}" - ConanName.validate_name(revision, message=message) + ConanName.validate_name(revision, reference_token="revision") obj = super(cls, PackageReference).__new__(cls, conan, package_id) obj.revision = revision return obj diff --git a/conans/test/command/new_test.py b/conans/test/command/new_test.py index 558e352ac2d..4237bbde499 100644 --- a/conans/test/command/new_test.py +++ b/conans/test/command/new_test.py @@ -32,7 +32,7 @@ def new_error_test(self): "names must contain at least 2 characters.", client.user_io.out) error = client.run('new A2/1.3@myuser/u', ignore_error=True) self.assertTrue(error) - self.assertIn("ERROR: Value provided for package user, 'u' (type str), is too short. Valid " + self.assertIn("ERROR: Value provided for channel, 'u' (type str), is too short. Valid " "names must contain at least 2 characters.", client.user_io.out) def new_dash_test(self): diff --git a/conans/test/model/ref_test.py b/conans/test/model/ref_test.py index bdf54cb587e..9a3965c4dc8 100644 --- a/conans/test/model/ref_test.py +++ b/conans/test/model/ref_test.py @@ -76,21 +76,3 @@ def validate_name_version_test(self): def validate_name_version_test_invalid(self): self._check_invalid_format("[no.close.bracket", True) self._check_invalid_format("no.open.bracket]", True) - - def custom_message_test_invalid_type(self): - message = "value={value}, type={type}, reason={reason}" - value = 1234 - typename = type(value).__name__ - reason = "is not a string" - with self.assertRaisesRegexp(InvalidNameException, - message.format(value=value, type=typename, reason=reason)): - ConanName.validate_name(value, message=message) - - def custom_message_test_invalid_format(self): - message = "value={value}, type={type}, reason={reason}" - value = "-no.dash.start" - typename = type(value).__name__ - reason = "is an invalid name" # Message is longer, but it will validate. - with self.assertRaisesRegexp(InvalidNameException, - message.format(value=value, type=typename, reason=reason)): - ConanName.validate_name(value, message=message) From 98ad1776386d0d0203476551cca3b4a12ba7b326 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Thu, 6 Sep 2018 11:27:18 +0200 Subject: [PATCH 11/11] minor changes: address @lasote review --- conans/model/ref.py | 3 +-- conans/test/model/ref_test.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conans/model/ref.py b/conans/model/ref.py index 494b50a8142..8fd25f75055 100644 --- a/conans/model/ref.py +++ b/conans/model/ref.py @@ -6,7 +6,7 @@ class ConanName(object): - _max_chars = 50 + _max_chars = 51 _min_chars = 2 _validation_pattern = re.compile("^[a-zA-Z0-9_][a-zA-Z0-9_\+\.-]{%s,%s}$" % (_min_chars - 1, _max_chars - 1)) @@ -49,7 +49,6 @@ def validate_name(name, version=False, reference_token=None): return if ConanName._validation_pattern.match(name) is None: if version and name.startswith("[") and name.endswith("]"): - # TODO: Check value between brackets return ConanName.invalid_name_message(name, reference_token=reference_token) diff --git a/conans/test/model/ref_test.py b/conans/test/model/ref_test.py index 9a3965c4dc8..0940e8edc86 100644 --- a/conans/test/model/ref_test.py +++ b/conans/test/model/ref_test.py @@ -60,6 +60,7 @@ def validate_name_test(self): self.assertIsNone(ConanName.validate_name("*")) self.assertIsNone(ConanName.validate_name("a" * ConanName._min_chars)) self.assertIsNone(ConanName.validate_name("a" * ConanName._max_chars)) + self.assertIsNone(ConanName.validate_name("a" * 50)) # Regression test def validate_name_test_invalid_format(self): self._check_invalid_format("-no.dash.start")