Skip to content

Removed str_starts_with and str_end_with calls #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Unreleased]

### Fixed
- Replaced function calls only available in PHP 8 with generic ones
[#524](https://github.com./nextcloud/cookbook/pull/524) @christianlupus

## 0.7.9 - 2021-01-15

### Changed
Expand Down
6 changes: 4 additions & 2 deletions lib/Helper/RestParameterParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ private function parseUrlEncoded(string $encoding): array {
$key = $parts[0];
$value = urldecode($parts[1]);

if (str_ends_with($key, '[]')) {
if (substr_compare($key, '[]', -2, 2)) {
// $key ends in []
// Drop '[]' at the end
$key = substr($key, 0, -2);

Expand Down Expand Up @@ -129,7 +130,8 @@ private function getEncoding(string $header): string {
$enc = 'UTF-8';

for ($i = 1; $i < count($parts); $i++) {
if (str_starts_with(trim($parts[$i]), self::CHARSET)) {
if (substr_compare(trim($parts[$i]), self::CHARSET, 0, strlen(self::CHARSET))) {
// parts[$i] begins with charset=
// Drop string 'charset='
$enc = substr(trim($parts[1]), strlen(self::CHARSET) + 1);
break;
Expand Down