No need to check if the first character is a number. This is already validated before.
This commit is contained in:
@@ -1894,6 +1894,10 @@ def create_gem(gem_path: str,
|
||||
# gem name is now the last component of the gem_path
|
||||
gem_name = os.path.basename(gem_path)
|
||||
|
||||
if not utils.validate_identifier(gem_name):
|
||||
logger.error(f'Gem name must be fewer than 64 characters, contain only alphanumeric, "_" or "-" characters, and start with a letter. {gem_name}')
|
||||
return 1
|
||||
|
||||
# gem name cannot be the same as a restricted platform name
|
||||
if gem_name in restricted_platforms:
|
||||
logger.error(f'Gem path cannot be a restricted name. {gem_name}')
|
||||
|
||||
@@ -46,9 +46,6 @@ def sanitize_identifier_for_cpp(identifier: str) -> str:
|
||||
return ''
|
||||
|
||||
sanitized_identifier = list(identifier)
|
||||
if not (sanitized_identifier[0].isalpha() or sanitized_identifier[0] == '_'):
|
||||
sanitized_identifier.insert(0, '_')
|
||||
|
||||
for index, character in enumerate(sanitized_identifier):
|
||||
if not (character.isalnum() or character == '_'):
|
||||
sanitized_identifier[index] = '_'
|
||||
|
||||
Reference in New Issue
Block a user