Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Decode URL so that no % signs are passed to sprintf#355

Open
shaedrich wants to merge 2 commits intophp-vcr:masterfrom
shaedrich:patch-1
Open

Decode URL so that no % signs are passed to sprintf#355
shaedrich wants to merge 2 commits intophp-vcr:masterfrom
shaedrich:patch-1

Conversation

@shaedrich
Copy link

@shaedrich shaedrich commented Aug 19, 2021

Context

When you have an url like this:
https://example.com/users?filter%5B0%5D%5Bhidden_infos%5D=&filter%5B0%5D%5Bstatus%5D%5Bis_parked%5D=0&filter%5B0%5D%5Bstatus%5D%5Bis_cancelled%5D=0&filter%5B0%5D%5Bstatus%5D%5Bis_paid%5D=1&filter%5B0%5D%5Bplatform%5D%5Boperator%5D=%21%3D&filter%5B0%5D%5Bplatform%5D%5Bvalue%5D=Amazon-Shop&filter%5B0%5D%5Binfos%5D%5Boperator%5D=%21%7E&filter%5B0%5D%5Binfos%5D%5Bvalue%5D=%2AAmazon+Prime%2A&filter%5B1%5D%5Bhidden_infos%5D=&filter%5B1%5D%5Bstatus%5D%5Bis_parked%5D=0&filter%5B1%5D%5Bstatus%5D%5Bis_cancelled%5D=0&filter%5B1%5D%5Bpayment_method_id%5D%5B0%5D=COD&filter%5B1%5D%5Bpayment_method_id%5D%5B1%5D=OnAccount&filter%5B1%5D%5Bpayment_method_id%5D%5B2%5D=hui&filter%5B1%5D%5Bpayment_method_id%5D%5B3%5D=hp_bs&filter%5B1%5D%5Bpayment_method_id%5D%5B4%5D=hp_ivpg&filter%5B2%5D%5Bhidden_infos%5D=&filter%5B2%5D%5Bstatus%5D%5Bis_parked%5D=0&filter%5B2%5D%5Bstatus%5D%5Bis_cancelled%5D=0&filter%5B2%5D%5Bstatus%5D%5Bis_paid%5D=1&filter%5B2%5D%5Bstatus%5D%5Bis_packed%5D=1&filter%5B2%5D%5Bplatform%5D=Amazon-Shop&filter%5B2%5D%5Binfos%5D%5Boperator%5D=%7E&filter%5B2%5D%5Binfos%5D%5Bvalue%5D=%2AAmazon+Prime%2A&select%5Bno_history%5D=1&select%5Bid%5D=&select%5Bdate%5D=&select%5Bportal_account_id%5D=&select%5Bplatform%5D=&select%5Binvoice_number%5D=&select%5Bexternal_order_id%5D=&select%5Bcurrent_date%5D=&select%5Bcustomer%5D=&select%5Bshipping%5D%5Bfee%5D=&select%5Bshipping%5D%5Bdate%5D=&select%5Bshipping%5D%5Bdeliverer%5D=&select%5Bshipping%5D%5Bcode%5D=&select%5Bshipping%5D%5Bmethod%5D=&select%5Bshipping%5D%5Baddress%5D=&select%5Bshipping%5D%5Bprime_label%5D=&select%5Bshipping%5D%5Bplatform_status%5D=&select%5Bline%5D=&select%5Bstatus%5D=&select%5Binvoice_amount%5D=&select%5Bpaid_amount%5D=&select%5Bcurrency_id%5D=&select%5Bpayment_method_id%5D=&select%5Bpack_infos%5D=&select%5Binfos%5D=&select%5Bbill_url%5D=&select%5Badd_field%5D=&select%5Bhidden_infos%5D=&select%5Bcredit%5D=&pagination%5Bmin_id%5D=0_2021_7&pagination%5Blimit%5D=200

sprintf() in beberlei/assert/lib/Assert/Assertion.php on line 1149 throws:

Unknown format specifier "B"

That is because encoded url parts (starting with %) are mistaken for sprintf format specifiers (also starting with %)

What has been done

  • wrapped $request->getUrl() in urldecode() in HttpClient::send() before passing it to Assertion::isResource()

How to test

  • Call Assertion::isResource($ch, "Could not init curl with URL '{$request->getUrl()}'") with the given URL above

Todo

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant