Skip to content

Commit fb10c94

Browse files
authored
Fix case sensitivity of folder attribute parsing (\NoSelect, \NoInferiors) #469 (#571)
* Fix case sensitivity of folder attribute parsing (\NoSelect, \NoInferiors) #469 * changelog update
1 parent 700485f commit fb10c94

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## [UNRELEASED]
88
### Fixed
9-
- NaN
9+
- Fix case sensitivity of Folder attribute parsing (\NoSelect, \NoInferiors) #469 (thanks @smajti1)
1010

1111
### Added
1212
- SSL stream context options added #238 #546 (thanks @llemoine)

src/Folder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ protected function getSimpleName($delimiter, $full_name): string|bool {
259259
* @param $attributes
260260
*/
261261
protected function parseAttributes($attributes): void {
262-
$this->no_inferiors = in_array('\NoInferiors', $attributes);
263-
$this->no_select = in_array('\NoSelect', $attributes);
262+
$this->no_inferiors = in_array('\NoInferiors', $attributes, true) || \in_array('\Noinferiors', $attributes, true);
263+
$this->no_select = in_array('\NoSelect', $attributes, true) || \in_array('\Noselect', $attributes, true);
264264
$this->marked = in_array('\Marked', $attributes);
265265
$this->referral = in_array('\Referral', $attributes);
266266
$this->has_children = in_array('\HasChildren', $attributes);

tests/issues/Issue469Test.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Tests\issues;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Webklex\PHPIMAP\Client;
7+
use Webklex\PHPIMAP\Folder;
8+
9+
class Issue469Test extends TestCase {
10+
11+
/**
12+
* Test issue #469 - Case sensitive \NoSelect flag check doesn't work for Gmail
13+
*/
14+
public function testIssue(): void {
15+
$client = $this->createStub(Client::class);
16+
$folder_name = '[Gmail]';
17+
$delimiter = '/';
18+
19+
$attributes = [
20+
'\NoInferiors',
21+
'\NoSelect',
22+
];
23+
$folder = new Folder($client, $folder_name, $delimiter, $attributes);
24+
25+
$attributes_lowercase = [
26+
'\Noinferiors',
27+
'\Noselect',
28+
];
29+
$folder_lowercase = new Folder($client, $folder_name, $delimiter, $attributes_lowercase);
30+
31+
self::assertSame(
32+
$folder->no_inferiors,
33+
$folder_lowercase->no_inferiors,
34+
'The parsed "\NoInferiors" attribute does not match the parsed "\Noinferiors" attribute'
35+
);
36+
self::assertSame(
37+
$folder->no_select,
38+
$folder_lowercase->no_select,
39+
'The parsed "\NoSelect" attribute does not match the parsed "\Noselect" attribute'
40+
);
41+
}
42+
}

0 commit comments

Comments
 (0)