The URL was incorrectly set when any of ;/?:@&=+$,# was used
in the folder name.
We have to mimetise what it is done in createFolder message selector.
That is, perform the IMAP4 encoding + URL encoding without CSS
encoding. The IMAP4 + CSS encoding (without URL encoding) is used to store the folder
in SOGo and OpenChange Indexing database as we do right now.
This is happening when importing a PST file.
From -> PidTagSenderEntryId
To -> PidTagOriginalDisplayTo
CC -> PidTagOriginalDisplayCc
The tested EntryID are the local users and OneOffEntries
when the users are not from the directory.
It requires https://github.com/openchange/openchange/pull/175 to work.
We activate the user for the context using the root folder
context as there are times where the active user is not
matching with the one stored in the application context
and SOGo object is storing cached data with the wrong user
leading to create folders in wrong mailboxes, etc.
As this application is single-threaded, no problems are expected.
Indeed, the same code is available at getting the root folder (ie INBOX).
By getting the root folder/container whose properties
are stored in OpenChange DB.
This makes the synchronisation of sub-folders faster as
when we evaluate restrictions for this folder, we are able
to get the modseq from where to get the latest messages
unseen by the client.
This may happen if between sync cache and setChangeKey a modSeq
is making synchroniseCache not retrieve the newly stored message.
This should fix the following crash:
https://tracker.zentyal.org/issues/2673
Valgrind crafted report:
=40967== 128,927 (53,750 direct, 75,177 indirect) bytes in 383 blocks are definitely lost in loss record 10,104 of 10,179
==40967== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==40967== by 0x86EDE3D: talloc_strndup (talloc.c:613)
==40967== by 0x34D2BB9E: _i_NSString_MAPIStoreDataTypes_asUnicodeInMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==40967== by 0x34D2025B: _i_MAPIStoreMailMessage__getPidTagNormalizedSubject_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==40967== by 0x34CFCD40: _i_MAPIStoreObject__getProperty_withTag_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==40967== by 0x34CFBE21: _i_MAPIStoreMessage__getPidTagSubject_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==40967== by 0x34CFBEB6: _i_MAPIStoreMessage__getPidTagOriginalSubject_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==40967== by 0x34CFCD40: _i_MAPIStoreObject__getProperty_withTag_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==40967== by 0x34CFD07E: _i_MAPIStoreObject__getProperties_withTags_andCount_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
This is happening when the lastModSeq is greater than the modseq
from an old message and that message is not in cache.
This is used as last resort before crashing and it is only used
in objectVersion as it is the first place to call on sync. Other
related properties would work.
And remove that entry from the indexing table.
This avoids to crash getting properties from a no longer available message
in the IMAP server, for instance, the `PidTagPredecessorChangeList` attribute.
By keeping mid on moving messages by soft deleting and
only if srcMid is different from targetMid.
This makes restore/shared deleted items work.
It also requires to do the following to work smoothly:
* Do not add soft-deleted messages in ensureIDsForChildKeys
* Return soft-deleted messages on getDeletedFMIDs
* Do not register a new mid if the URL is matched with soft deleted messages
Furthermore, [MS-OXOCAL] Section 2.2.1.41.1 indicates:
The wDay field is set to indicate
the occurrence of the day of the week within the month
(1 to 5, where 5 indicates the final occurrence during
the month if that day of the week does not occur 5 times).
[rule firstOccurrence] may return negative values according to iCal spec for
recurrent rules iCal 4.8.5.4 Recurrence Rule. For instance, for defining
a timezone whose recurrent rule is done using this rule:
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
This fixes the problem when editing a recurrent appointment in
Outlook were incorrectly shifted when SOGo provides back the event.
Fetching a body[text] property using IMAP makes IMAP server set seen flag.
This commit fetches the flag beforehand to restore the previous state
once the body has been fetched.
This avoids to crash on this example:
\f0\fibi \fcharset0
-------^
Or:
\f0 \fibi\fcharset0
--^
Take into account that I found lots of RTF documents with this format:
\f0\fbidi \froman\fcharset0
\f0\froman\fprq2 \fcharset0
Which are not unsupported by this handler.
Map: FreeBusySimple -> PublicDAndTViewer
FreeBusyDetailed -> ConfidentialDAndTViewer
Although SOGo is not really used AFAIK, we can now keep it and
keep Calendar permission issues consistent.
We have a cache with user contexts (objc) which have mapping contexts (objc)
where we store the indexing context (c) which will be freed by openchange
code once the connection is closed.
Right now all indexing context created for an user are the same,
independently when in time was created or by which connection, etc...
So this is a valid workaround, but this has to be refactored to used the
indexing context of the current connection that is performing the
call to SOGo backend.
This was causing to parse a single space as an empty control
word with length 0, which was the source of several crashes.
Example:
\f0\fbidi \fcharset0
--------^
font index is 0, font family is bidi but when parsing charset we were
assuming control word was '' instead of 'charset0'.
This only fixes the crashes, the parseFontTable function works quite
awful right now.
Different types for keys in Dictionaries leads to not finding
expected entry - we should make sure that everythime we set/get
entry from a dictionary, key object type is same
toManyRelationshipKeysWithNamespaces applies asCSSIdentifier function
to the names which are already "Imap4Encoded". So we need to remove the
CSSIdentifier function first and then "Imap4Decode" to get the real name.
Once we have the real name, to create the url we have to use the same
logic as the function that creates the folder and creates this url for
the first time (this function is createRootSecondaryFolderWithFID)
which is to apply, in this order:
- asCSSIdentifier
- stringByEncodingImap4FolderName
- stringByAddingPercentEscapesUsingEncoding
In a multithread environment, sogo_backend_init is registering the thread
only for the first one that calls this function, then the others threads
(even if they call sogo_backend_init) won't be registered because
moduleInitialized was YES.
We just want to ensure sogo_backend_init is called at least once (per process,
not per thread).
Also, implement reading for message data in case only 1 param is passed.
This could be usefull when have msg data by other means than by
reading it directly from DB
Signed-off-by: Kamen Mazdrashki <kmazdrashki@zentyal.com>
We have thread context already in place during *_init() function.
Thus guarding every API call with TreadInit/Destroy is:
- a bit redundand
- makes SOGo backend not reentrant even on single thread and leads
to hard to find use-after-free crashes
Signed-off-by: Kamen Mazdrashki <kmazdrashki@zentyal.com>
Usually, it is a bad idea for an object to call its own public methods
(just like in this case). Thus separating impelementation for deleteFolder:
would allow MAPIStoreFolder to call only private implementation when needed
Signed-off-by: Kamen Mazdrashki <kmazdrashki@zentyal.com>
possible range of recepients
IMHO, this fixes a bug, that when saving a meessage, it is saved
without BCC fields.
Signed-off-by: Kamen Mazdrashki <kmazdrashki@zentyal.com>
Most of the time we have "not yet implemented" kind of exceptions,
so it is better to clean up allocated resources
Signed-off-by: Kamen Mazdrashki <kmazdrashki@zentyal.com>