Skip to content

[BUG] Lookup API dropped CGI escape of spaces in phone number values #784

@mcon85

Description

@mcon85

Describe the bug

In the latest (7.10.4) release the phone number value for validation no longer does CGI escaping of spaces which results in an error when validating a phone number with a space in it. This looks to be a recurring regression that has been patched in the past: #468

Current:

@uri = "/PhoneNumbers/#{@solution[:phone_number]}"

Previously:
https://github.com/twilio/twilio-ruby/blame/c84cb9b18e787e02bd66511103367bbb68a97a79/lib/twilio-ruby/rest/lookups/v1/phone_number.rb#L54

@uri = "/PhoneNumbers/#{CGI.escape(@solution[:phone_number]).gsub("+", "%20")}"

Code snippet

https://lookups.twilio.com/v1/PhoneNumbers/555 555 5555

Actual behavior

When given "555 555 5555" as a phone number value validation errors because of the spaces in the phone value now that the value is no longer CGI escaped.

Expected behavior

If given phone "555 555 5555" it should be possible to validate without error.

twilio-ruby version

7.10.3

Ruby version

3.3.2

Logs or error messages

bad URI(is not URI?): "https://lookups.twilio.com/v1/PhoneNumbers/555 555 5555"

Additional context

The value still containing spaces results in URI::InvalidURIError errors within Faraday's URI.parse() call when the URL looks like
https://lookups.twilio.com/v1/PhoneNumbers/555 555 5555

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugbug in the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions