Commit Graph

1285 Commits

Author SHA1 Message Date
52f6184e88 fix: must init raw pointer *bodyPart
All checks were successful
Compilation test / build (push) Successful in 15m13s
2024-12-01 19:26:23 +01:00
fd0b5f7a21 fix: should not use mlang in such a way in mingw
All checks were successful
Compilation test / build (push) Successful in 14m24s
2024-12-01 02:32:41 +01:00
193a9ee85b feat: remember boundary from parsing
All checks were successful
Compilation test / build (push) Successful in 15m19s
2024-11-28 12:00:39 +01:00
Jan Engelhardt
43b262bd8c
gh: add a GitHub workflow for compile+testsuite testing (#313)
This will cause all pushed commits and pull requests to be
fed through a compile and testsuite run.
2024-06-11 21:01:01 +02:00
Jan Engelhardt
beb238b5e7
Fix a test failure in pathTest::testGenerate (#312)
* Fix a test failure in testNewFromString

Fixes an oversight in d296c2d1.

* Fix a test failure in pathTest::testGenerate

Partially revert v0.9.2-183-g9b65b4de.

As per RFC 5322 §3.4.1, an email address must always have a @.
As per RFC 5321 §4.1.2, a path is similar to an email address (always
@), with "" (<>) being the only other special value.

Fixes #294, #301.
2024-06-11 20:49:10 +02:00
Jan Engelhardt
aa60d00496
Fix a test failure in testNewFromString (#311)
Fixes an oversight in d296c2d1.
2024-06-11 20:47:53 +02:00
Jan Engelhardt
0f7014ab57
build: upgrade to C++17 when ICU is used (#310)
ICU 75 requires the use of C++17.

`SET(CMAKE_CXX_STANDARD 17)` has no effect after the first target has been defined
or so, therefore the detection of the conversion library is split and partially
moved upwards.
2024-06-11 20:46:59 +02:00
Jan Engelhardt
fb5b82746a
contrib: update utfcpp to v4.0.5 (#309)
Download a new version from https://github.com/nemtrif/utfcpp/
which explicitly supports C++17.
2024-06-11 20:45:51 +02:00
Jan Engelhardt
5f8fa22602
build: resolve a -Wunused-function compiler warning (#308)
posixSocket.cpp:67:7: warning: ‘char*
{anonymous}::vmime_strerror_r_result(int, char*)’ defined but not
used [-Wunused-function]
   67 | char* vmime_strerror_r_result(int /* res */, char* buf) {

It is to be expected that one of the two r_result functions is going unused,
depending on whichever platform we are currently building on.
2024-06-11 20:44:18 +02:00
Jan Engelhardt
a2636bd4ae
asciiPercent computation: another potential multiplication overflow (#307)
* build: resolve a -Wconversion compiler warning

wordEncoder.cpp:312:91: warning: conversion from
‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned
int’} to ‘double’ may change value [-Wconversion]
  312 | buffer.length() == 0 ? 1 : static_cast<double>(asciiCount) / buffer.length();
      |                                                              ~~~~~~~~~~~~~^~

* wordEncoder: replace value 100 for asciiPercent

asciiPercent is a ratio, and not counting in units of hundredths
anymore. The maximum value therefore should be 1 not 100.

* vmime: avoid integer multiply wraparound in text::createFromString

The change from commit v0.9.2-194-gb447adbe needs to be applied to
one more function that replicates the same code.

(If the input string is 42949673 characters long or larger, there will
be integer overflow on 32-bit platforms when multiplying by 100.
Switch that one computation to floating point.)
2024-05-21 20:48:08 +02:00
Jan Engelhardt
d296c2d1d5
vmime: prevent loss of a space during text::createFromString (#306)
```
mailbox(text("Test München West", charsets::UTF_8), "a@b.de").generate();
```

produces

```
=?us-ascii?Q?Test_?= =?utf-8?Q?M=C3=BCnchen?= =?us-ascii?Q?West?= <test@example.com>
```

The first space between ``Test`` and ``München`` is encoded as an
underscore along with the first word: ``Test_``. The second space
between ``München`` and ``West`` is encoded with neither of the two
words and thus lost. Decoding the text results in ``Test
MünchenWest`` instead of ``Test München West``.

This is caused by how ``vmime::text::createFromString()`` handles
transitions between 7-bit and 8-bit words: If an 8-bit word follows a
7-bit word, a space is appended to the previous word. The opposite
case of a 7-bit word following an 8-bit word *misses* this behaviour.

When one fixes this problem, a follow-up issue appears:

``text::createFromString("a b\xFFc d")`` tokenizes the input into
``m_words={word("a "), word("b\xFFc ", utf8), word("d")}``. This
"right-side alignment" nature of the whitespace is a problem for
word::generate():

As per RFC 2047, spaces between adjacent encoded words are just
separators but not meant to be displayed. A space between an encoded
word and a regular ASCII text is not just a separator but also meant
to be displayed.

When word::generate() outputs the b-word, it would have to strip one
space, but only when there is a transition from encoded-word to
unencoded word. word::generate() does not know whether d will be
encoded or unencoded.

The idea now is that we could change the tokenization of
``text::createFromString`` such that whitespace is at the *start* of
words rather than at the end. With that, word::generate() need not
know anything about the next word, but rather only the *previous*
one.

Thus, in this patch,

1. The tokenization of ``text::createFromString`` is changed to
   left-align spaces and the function is fixed to account for
   the missing space on transition.
2. ``word::generate`` learns how to steal a space character.
3. Testcases are adjusted to account for the shifted
   position of the space.

Fixes: #283, #284

Co-authored-by: Vincent Richard <vincent@vincent-richard.net>
2024-05-21 15:55:06 +02:00
Jan Engelhardt
c105165c6e
tests: switch a byte sequence in textTest (#305)
Switch out the byte sequence by one that is simiarly random, but one
which happens to decode as valid UTF-8, such that the expected and
actual strings are shown with reasonable characters on a terminal.
2024-05-21 15:48:26 +02:00
Jan Engelhardt
b447adbe37
Fixes/comments for guessBestEncoding (#304)
* tests: add case for getRecommendedEncoding

* vmime: avoid integer multiply wraparound in wordEncoder::guessBestEncoding

If the input string is 42949673 characters long or larger, there will
be integer overflow on 32-bit platforms when multiplying by 100.
Switch that one computation to floating point.

* vmime: update comment in wordEncoder::guessBestEncoding
2024-05-21 15:47:05 +02:00
Jan Engelhardt
97d15b8cd7
vmime: avoid changing SEVEN_BIT when encoding::decideImpl sees U+007F (#303)
* vmime: avoid changing SEVEN_BIT when encoding::decideImpl sees U+007F

Do not switch to QP/B64 when encountering U+007F.
U+007F is part of ASCII just as much as U+0001 is.

---------

Co-authored-by: Vincent Richard <vincent@vincent-richard.net>
2024-05-21 15:45:29 +02:00
Jan Engelhardt
15f3b94580
Resolve compiler warnings (#302)
* build: replace class noncopyable by C++11 deleted function declaration

C++11 is mandatory since commit v0.9.2-48-g8564b2f8, therefore we can
exercise the =delete keyword in class declarations to prohibit
copying.

* build: resolve -Woverloaded-virtual warnings

context.hpp:109:26: warning: "virtual vmime::context&
vmime::context::operator=(const vmime::context&)’ was hidden
[-Woverloaded-virtual=]
  109 |         virtual context& operator=(const context& ctx);
      |                          ^~~~~~~~
generationContext.hpp:153:28: note:   by ‘vmime::generationContext&
vmime::generationContext::operator=(const vmime::generationContext&)’
  153 |         generationContext& operator=(const generationContext& ctx);
      |                            ^~~~~~~~

AFAICS, there is no point in having "virtual" on an assignment operator.
Any derived classes' operator= has different signature anyway.
It is also the only class with a virtual operator=, so that's an indicator
for oddness as well.

* build: resolve -Wdeprecated-declarations warnings

encoding.cpp: In static member function "static const vmime::encoding
vmime::encoding::decideImpl(std::__cxx11::basic_string<char>::const_iterator,
std::__cxx11::basic_string<char>::const_iterator)":

encoding.cpp:161:29: warning: "std::binder2nd<_Operation>
std::bind2nd(const _Operation&, const _Tp&) [with _Operation =
less<unsigned char>; _Tp = int]" is deprecated: use "std::bind" instead
[-Wdeprecated-declarations]
  161 |                 std::bind2nd(std::less<unsigned char>(), 127)
      |                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

C++11 is mandatory, so just use a lambda already.
2024-05-21 15:41:50 +02:00
Ján Osuský
d03ad5f0f6
Fix OpenSSL initialization #299 (#300) 2024-03-04 11:48:48 +01:00
Jan Engelhardt
0ce327abee
url: strip leading slash from url-path (#298) 2024-03-04 11:46:03 +01:00
Jan Engelhardt
c6b01fcc32
url: repair off-by-one bug in extractHost (#297)
`hostPart[len]` is pointing to `]`, but we need to check the
char after that.

Fixes: v0.9.2-187-g874a1d8c
2024-03-04 11:45:49 +01:00
Jan Engelhardt
c3c6242ed1
url: add remark to documentation about hardcoded // substring (#293) 2024-01-30 12:41:49 +01:00
Jan Engelhardt
874a1d8c33
url: support IPv6 literals (RFC 2732) (#292) 2024-01-30 12:38:41 +01:00
Vincent Richard
8bed1cc743
Fixed confusing source/bin dirs in makefile. (#291) 2024-01-12 13:36:00 +01:00
vincent-richard
a5623d695f Fixed use of old API (#287). 2024-01-01 18:02:32 +01:00
bmagistro
6fd4de8fb5
Add parsing feedback via parsingContext (#280)
* Add parsing feedback via parsingContext

Changes the parsing context to be modifiable to be able to provide
feedback on the parsing. This allows the user to check if header
recovery was necessary, for example, while parsing the current message.

Signed-off-by: Ben Magistro <koncept1@gmail.com>
Co-authored-by: Vincent Richard <vincent@vincent-richard.net>
2023-12-31 16:10:18 +01:00
bmagistro
9b65b4de6c
Configurable email add domain (#287)
* Allow appending of local hostname to be configured via parsing context

Signed-off-by: Ben Magistro <koncept1@gmail.com>
Co-authored-by: Vincent Richard <vincent@vincent-richard.net>
2023-12-31 16:03:30 +01:00
Jan Engelhardt
acfc0bbf82
Avoid generating illegal Envelope-From with sendmail:// transport (#285)
When the ``sender`` function argument is the empty object, vmime
would still attempt to use it at ``sender.getEmail().generate()``,
but that produces just ``@``. As sendmail is called with ``-f @``,
this shows up in postfix's logs as ``<""@>``.
2023-12-31 15:56:28 +01:00
bmagistro
022303bbc9
Build: static lib dependency for ICU (#281)
* Fix missed path for generated files in #277

* Update cmake to include char conversion dependency on static library
2023-12-31 15:54:48 +01:00
bmagistro
7ada1c974c
Build: fix missed path for generated files in #277 (#278) 2023-12-31 15:35:57 +01:00
Jan Engelhardt
82377e0342
Build: add FreeBSD & libc++ compilation support (#288)
* build: add FreeBSD compilation support

* build: unbreak compilation with clang libc++

unary_function is obsolete with C++11 and removed in C++17.
gnu-gcc-libstdc++ still has the class, but llvm-clang-libc++ does
not, and there is a compile error.

vmime should have just stopped using unary_function with commit
v0.9.2-48-g8564b2f8.

	$ cat x.cpp
	$ clang++ -std=c++17 -stdlib=libc++ -c x.cpp
	In file included from x.cpp:1:
	In file included from /usr/local/include/vmime/net/transport.hpp:34:
	In file included from /usr/local/include/vmime/net/service.hpp:36:
	In file included from /usr/local/include/vmime/net/session.hpp:40:
	In file included from /usr/local/include/vmime/utility/url.hpp:30:
	/usr/local/include/vmime/propertySet.hpp:339:33: error: no template named
	/'unary_function' in namespace 'std'; did you mean '__unary_function'?
		class propFinder : public std::unary_function <shared_ptr <property>, bool> {
					  ~~~~~^~~~~~~~~~~~~~
					       __unary_function
2023-12-31 15:22:36 +01:00
bmagistro
6e11c9c9f8
Make default context thread_local (#286)
* Make default context thread_local

Signed-off-by: Ben Magistro <koncept1@gmail.com>
Co-authored-by: Vincent Richard <vincent@vincent-richard.net>
2023-12-31 15:19:28 +01:00
Jan Engelhardt
1a35bb6d71
Build: add Solaris compilation support (#282) 2023-11-09 20:32:47 +01:00
bmagistro
c6b9ad3c78
Update cmake (#277)
This restructures the cmake a little bit to only find components if they
are actually enabled.  It also rearranges things to better group some
related items.  This change also fixes include directories for the build
target allowing the library to be embedded making the install step
optional.

Signed-off-by: Ben Magistro <koncept1@gmail.com>
2023-08-09 10:59:38 +02:00
Vincent Richard
fc69321d53
Merge pull request #272 from frodegill/bytearray_to_string
Utility function to convert byteArray to HEX string. Useful for printing fingerprint digests etc.
2022-03-26 22:30:00 +01:00
Vincent Richard
56b77ca3b7
Merge pull request #271 from frodegill/digest_sha256
Added support for digest algorithm SHA256
2022-03-26 22:19:47 +01:00
Frode Roxrud Gill
6fd3632912 Added utility function to convert byteArray to HEX string. Useful for printing fingerprint digests etc. 2022-03-13 11:59:02 +01:00
Frode Roxrud Gill
46c09fa8a5
Merge pull request #1 from frodegill/digest_sha256
Added support for digest algorithm SHA256
2022-03-13 11:54:16 +01:00
Frode Roxrud Gill
cd59fabe79 Added support for digest algorithm SHA256 2022-03-13 11:44:27 +01:00
vincent-richard
561746081f Fixed possible recursion crash when parsing mailbox groups. 2022-01-25 10:28:20 +01:00
Vincent Richard
23ab2a6a3c Fixed Cppcheck issues. 2021-11-25 21:57:07 +01:00
Vincent Richard
80ad529d5a #268 Code style fixes + moved specific bits to IMAP namespace 2021-11-25 21:23:50 +01:00
Vincent Richard
c6e3b759bc
Merge pull request #268 from jacadcaps/search
Implemented IMAP SEARCH.
2021-11-25 20:22:50 +01:00
Jacek Piszczek
1a0a22a311 Implemented IMAP SEARCH 2021-10-28 23:17:29 -04:00
Vincent Richard
edcb4b4b1f
Merge pull request #262 from ibanic/master
Prevent accessing empty buffer when using FilteredOutputStream with ICU
2021-05-16 18:43:14 +02:00
ibanic
f5fa6434aa fixed coding style 2021-05-16 09:43:32 +02:00
ibanic
5d78d879bb Prevent accessing empty buffer 2021-05-15 22:32:24 +02:00
vincent-richard
c86e4bcd3a #261 Workaround for bad SEARCH response with AOL IMAP server 2021-05-11 08:31:03 +02:00
vincent-richard
7503cd3747 #200 Fixed installation directory 2021-05-06 21:06:47 +02:00
vincent-richard
c6904bd7cf SMTP/DSN refactoring. 2021-04-03 11:21:50 +02:00
Vincent Richard
a6226e8cbc
Merge pull request #256 from jacadcaps/IMAP.PEEK
IMAP PEEK support.
2021-03-31 21:37:30 +02:00
Vincent Richard
8024c650a2
Merge pull request #258 from jacadcaps/processFetchResponse
Process Message-ID and In-Reply-To in ENVELOPE.
2021-03-31 21:22:13 +02:00
Jacek Piszczek
c0f2380aac Fixed build 2021-03-25 02:17:17 +01:00