CocoaPods/Core

Podspec name that includes `(` `)` triggers error on `pod install`

Closed this issue ยท 5 comments

I've found out that Podspec name like this - OneMobileSDK-Swift2.3(ObjC)

Will trigger this one error when executing pod install (this will cause no errors if there is no Podfile.lock ๐Ÿ˜„ ):

[!] Invalid string representation for a specification: `OneMobileSDK-Swift2.3(ObjC) (1.18.1081)`. The string representation should include the name and optionally the version of the Pod. `

This is coming from lib/cocoapods-core/specification.rb function:

def self.name_and_version_from_string(string_representation)
    match_data = string_representation.match(/\A((?:\s?[^\s(])+)(?: \((.+)\))?\Z/)

So the problem is in regexp which looks for version (123) and finds (ObjC).

So I see 2 possible solutions for this problem here:

  1. Update regexp.
  2. Do not allow podspecs with such names to pass validation.

A PR and a few tests is always welcome!

It is possible to add another optional group to the end of regular expression.
(?:\([^\s()]+\))?) - will handle (Objc) at the end of spec names.
Full regexp - \A((?:\s?[^\s(])+(?:\([^\s()]+\))?)(?: \((.+)\))?\Z

How many pods do we have with parenthesis? If none, I'd rather reject them

This affects any Pod name that needs to be escaped to be valid YAML, like !ProtoCompiler (https://github.com/CocoaPods/Specs/blob/d0ec5a65e80656c8d78e12ff19f251df879e0bc2/Specs/9/7/c/!ProtoCompiler-gRPCPlugin/0.14.0/!ProtoCompiler-gRPCPlugin.podspec.json)

It looks like this commit has an unintended side effect:

e830c06

I believe the pod !ProtoCompiler has been fixed now.

Going to close this as too old.