Skip to content

Commit 067c69f

Browse files
committed
Fix: Urlencode user IDs in URLs
The Alma user id can contain more or less any unicode character, so we should urlencode it.
1 parent c8f64f2 commit 067c69f

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

src/Users/Fee.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(Client $client, User $user, $id)
3131
*/
3232
protected function urlBase()
3333
{
34-
return "/users/{$this->user->id}/fees/{$this->id}";
34+
return sprintf('/users/%s/fees/%s', rawurlencode($this->user->id), $this->id);
3535
}
3636

3737
/**

src/Users/Fees.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ public function convertToResource($data)
6565
*/
6666
protected function urlBase()
6767
{
68-
return "/users/{$this->user->id}/fees";
68+
return sprintf('/users/%s/fees', rawurlencode($this->user->id));
6969
}
7070
}

src/Users/Loan.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(Client $client, User $user, $loan_id)
3131
*/
3232
protected function urlBase()
3333
{
34-
return "/users/{$this->user->id}/loans/{$this->loan_id}";
34+
return sprintf('/users/%s/loans/%s', rawurlencode($this->user->id), $this->loan_id);
3535
}
3636

3737
/**

src/Users/Loans.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ public function convertToResource($data)
5050
*/
5151
protected function urlBase()
5252
{
53-
return "/users/{$this->user->id}/loans";
53+
return sprintf('/users/%s/loans', $this->user->id);
5454
}
5555
}

src/Users/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ protected function isInitialized($data)
4242
*/
4343
protected function urlBase()
4444
{
45-
return "/users/{$this->user->id}/requests/{$this->request_id}";
45+
return sprintf('/users/%s/requests/%s', rawurlencode($this->user->id), $this->request_id);
4646
}
4747
}

src/Users/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function onData($data)
112112
*/
113113
protected function urlBase()
114114
{
115-
return "/users/{$this->id}";
115+
return sprintf('/users/%s', rawurlencode($this->id));
116116
}
117117

118118
public function __get($key)

0 commit comments

Comments
 (0)