Skip to content

Commit ed81c6d

Browse files
committed
Fix UID query quoting
1 parent 1cdf6fb commit ed81c6d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Connection/ImapQueryBuilder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ public function header(string $header, string $value): static
232232
*/
233233
public function uid(int|string|array $uid): static
234234
{
235-
return $this->where(ImapSearchKey::Uid, implode(',', (array) $uid));
235+
return $this->where(
236+
ImapSearchKey::Uid,
237+
new RawQueryValue(implode(',', (array) $uid))
238+
);
236239
}
237240

238241
/**

tests/Unit/Connection/ImapQueryBuilderTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,19 @@ function (ImapQueryBuilder $q) {
228228

229229
expect($builder->toImap())->toBe('FOO "Jou&AOk-"');
230230
});
231+
232+
test('compiles UID condition without quotes', function () {
233+
$builder = new ImapQueryBuilder;
234+
235+
$builder->uid(2);
236+
237+
expect($builder->toImap())->toBe('UID 2');
238+
});
239+
240+
test('compiles multiple UID values without quotes', function () {
241+
$builder = new ImapQueryBuilder;
242+
243+
$builder->uid([2, 3]);
244+
245+
expect($builder->toImap())->toBe('UID 2,3');
246+
});

0 commit comments

Comments
 (0)