oat-sa / lib-lti1p3-core

PHP library for LTI 1.3 Core implementations as platforms and / or as tools.
GNU General Public License v2.0
33 stars 16 forks source link

LtiMessage::toUrl() invalid when $this->url already contains query string #119

Closed ofabel closed 3 years ago

ofabel commented 3 years ago

As the title of this issue says: The LtiMessage::toUrl() method should generate a valid URL if the base URL already contains a query string. https://github.com/oat-sa/lib-lti1p3-core/blob/d840ce93ecd7511c2c03bd16cd09388eaba9101f/src/Message/LtiMessage.php#L80

A base url of http://localhost/mod/lti/contentitem_return.php?course=2&id=39&sesskey=BP0AlkCbZq results in the following return value from LtiMessage::toUrl() (which is invalid because of the double ?). http://localhost/mod/lti/contentitem_return.php?course=2&id=39&sesskey=BP0AlkCbZq?JWT=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjU1ZmQwNzIxMWY5ZDQ4MGVhOWVjNGIwNTU5ZGFiNzMwZGNlZmU4MjZhMDdmZjU5YjA5NDgxN2Q1NmRjZjJlNzYifQ.eyJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2x0aS1kbC9jbGFpbS9kYXRhIjpudWxsLCJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2x0aS1kbC9jbGFpbS9tc2ciOiIxIGl0ZW0ocykgcHJvdmlkZWQiLCJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2x0aS1kbC9jbGFpbS9sb2ciOiIxIGl0ZW0ocykgcHJvdmlkZWQiLCJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2x0aS1kbC9jbGFpbS9jb250ZW50X2l0ZW1zIjpbeyJ1cmwiOiJodHRwOi8vaG9zdC5kb2NrZXIuaW50ZXJuYWw6ODA4MC9sdGkvbGF1bmNoIiwidGl0bGUiOiJteSBmYW5jeSBweXRob24gdG9vbCIsInR5cGUiOiJsdGlSZXNvdXJjZUxpbmsifV0sImlzcyI6IlFZWXQ1WU5GQ1NRZEJ2by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