-
Notifications
You must be signed in to change notification settings - Fork 17
fix(activesync): refuse Draft Modify append-as-new for stale UIDs #201
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
ralflang
merged 2 commits into
FRAMEWORK_6_0
from
fix/activesync-draft-modify-stale-uid
Jul 21, 2026
+141
−2
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * Copyright 2026 The Horde Project (http://www.horde.org/) | ||
| * | ||
| * See the enclosed file LICENSE for license information (LGPL). If you | ||
| * did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
| * | ||
| * @author Torben Dannhauer <torben@dannhauer.de> | ||
| * @category Horde | ||
| * @copyright 2026 The Horde Project | ||
| * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
| * @package Core | ||
| * @subpackage UnitTests | ||
| */ | ||
|
|
||
| namespace Horde\Core\Test\Unit\ActiveSync; | ||
|
|
||
| use Horde\Http\ServerRequest; | ||
| use Horde_ActiveSync; | ||
| use Horde_ActiveSync_Device; | ||
| use Horde_ActiveSync_Imap_Adapter; | ||
| use Horde_ActiveSync_Message_AirSyncBaseBody; | ||
| use Horde_ActiveSync_Message_Mail; | ||
| use Horde_Core_ActiveSync_Auth; | ||
| use Horde_Core_ActiveSync_Connector; | ||
| use Horde_Core_ActiveSync_Driver; | ||
| use Horde_Log_Handler_Null; | ||
| use Horde_Log_Logger; | ||
| use Horde_Registry; | ||
| use PHPUnit\Framework\Attributes\CoversMethod; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| /** | ||
| * Defense-in-depth for Issue #85: Draft Modify must not append-as-new when | ||
| * the client ServerId is missing/stale on IMAP. | ||
| */ | ||
| #[CoversMethod(Horde_Core_ActiveSync_Driver::class, 'changeMessage')] | ||
| class DriverDraftModifyStaleUidTest extends TestCase | ||
| { | ||
| public function testDraftModifyMissingUidDoesNotAppend(): void | ||
| { | ||
| if (!class_exists('Horde_ActiveSync_Message_Mail')) { | ||
| $this->markTestSkipped('horde/activesync not available'); | ||
| } | ||
|
|
||
| $folder = 'INBOX/Drafts'; | ||
| $staleUid = 100; | ||
|
|
||
| $imap = $this->getMockBuilder(Horde_ActiveSync_Imap_Adapter::class) | ||
| ->disableOriginalConstructor() | ||
| ->onlyMethods(['getImapMessage', 'appendMessage', 'deleteMessages', 'getSpecialMailboxes', 'setLogger']) | ||
| ->getMock(); | ||
| $imap->method('getSpecialMailboxes')->willReturn([ | ||
| Horde_Core_ActiveSync_Driver::SPECIAL_DRAFTS => (object) ['value' => $folder], | ||
| ]); | ||
| $imap->expects($this->once()) | ||
| ->method('getImapMessage') | ||
| ->with($folder, $staleUid) | ||
| ->willReturn([]); | ||
| $imap->expects($this->never())->method('appendMessage'); | ||
| $imap->expects($this->never())->method('deleteMessages'); | ||
|
|
||
| $state = $this->getMockBuilder('Horde_ActiveSync_State_Sql') | ||
| ->disableOriginalConstructor() | ||
| ->getMock(); | ||
| $state->method('setLogger'); | ||
| $state->method('setBackend'); | ||
|
|
||
| $connector = $this->getMockBuilder(Horde_Core_ActiveSync_Connector::class) | ||
| ->disableOriginalConstructor() | ||
| ->getMock(); | ||
| $auth = $this->getMockBuilder(Horde_Core_ActiveSync_Auth::class) | ||
| ->disableOriginalConstructor() | ||
| ->getMock(); | ||
| $registry = $this->getMockBuilder(Horde_Registry::class) | ||
| ->disableOriginalConstructor() | ||
| ->getMock(); | ||
|
|
||
| $driver = new Horde_Core_ActiveSync_Driver([ | ||
| 'connector' => $connector, | ||
| 'auth' => $auth, | ||
| 'serverrequest' => new ServerRequest('POST', '/'), | ||
| 'registry' => $registry, | ||
| 'state' => $state, | ||
| 'imap' => $imap, | ||
| ]); | ||
| $driver->setLogger(new Horde_Log_Logger(new Horde_Log_Handler_Null())); | ||
| $driver->setProtocolVersion(Horde_ActiveSync::VERSION_SIXTEEN); | ||
|
|
||
| $userProp = new \ReflectionProperty( | ||
| \Horde_ActiveSync_Driver_Base::class, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use "use" statement here. |
||
| '_user' | ||
| ); | ||
| $userProp->setAccessible(true); | ||
| $userProp->setValue($driver, 'alice@example.com'); | ||
|
|
||
| $message = new Horde_ActiveSync_Message_Mail([ | ||
| 'protocolversion' => Horde_ActiveSync::VERSION_SIXTEEN, | ||
| ]); | ||
| $message->to = 'alice@example.com'; | ||
| $message->subject = 'Draft subject'; | ||
| $body = new Horde_ActiveSync_Message_AirSyncBaseBody([ | ||
| 'protocolversion' => Horde_ActiveSync::VERSION_SIXTEEN, | ||
| ]); | ||
| $body->type = Horde_ActiveSync::BODYPREF_TYPE_PLAIN; | ||
| $body->data = 'body'; | ||
| $message->airsyncbasebody = $body; | ||
|
|
||
| $device = $this->createMock(Horde_ActiveSync_Device::class); | ||
|
|
||
| $result = $driver->changeMessage($folder, $staleUid, $message, $device); | ||
|
|
||
| $this->assertFalse($result); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't to that - this is the release tool's job. You also create a mess as soon as another PR is released faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, i'll instruct my agents.md