# HG changeset patch # User Carl Byington # Date 1616881981 25200 # Node ID 24871e6cdd696980956dff0ec2cd320d253904cd # Parent 7200790e46ac817f9dcce0d5e119c73bd1b7c557 Stuart C. Naifeh - fix rfc2231 encoding when saving messages to both .eml and msg formats diff -r 7200790e46ac -r 24871e6cdd69 AUTHORS --- a/AUTHORS Tue Jun 16 17:18:28 2020 -0700 +++ b/AUTHORS Sat Mar 27 14:53:01 2021 -0700 @@ -47,6 +47,8 @@ Tim Dufrane Paul Wise + Markus Schnalke + Stuart C. Naifeh Testing team: Mac OSX - Michael Watson diff -r 7200790e46ac -r 24871e6cdd69 ChangeLog --- a/ChangeLog Tue Jun 16 17:18:28 2020 -0700 +++ b/ChangeLog Sat Mar 27 14:53:01 2021 -0700 @@ -1,3 +1,8 @@ +LibPST 0.6.76 (2021-03-27) +=============================== + * Stuart C. Naifeh - fix rfc2231 encoding when saving messages + to both .eml and .msg formats. + LibPST 0.6.75 (2020-03-22) =============================== * Markus Schnalke - fix from Debian for vcard version format. diff -r 7200790e46ac -r 24871e6cdd69 NEWS --- a/NEWS Tue Jun 16 17:18:28 2020 -0700 +++ b/NEWS Sat Mar 27 14:53:01 2021 -0700 @@ -1,3 +1,4 @@ +0.6.76 2021-03-27 Stuart C. Naifeh - fix rfc2231 encoding when saving messages to .eml and .msg formats. 0.6.75 2020-03-22 Markus Schnalke - fix from Debian for vcard version format. 0.6.74 2020-01-12 Paul Wise - many changes for Debian. 0.6.73 2019-07-25 Tim Dufrane - fix segfault in pst_close() diff -r 7200790e46ac -r 24871e6cdd69 configure.ac --- a/configure.ac Tue Jun 16 17:18:28 2020 -0700 +++ b/configure.ac Sat Mar 27 14:53:01 2021 -0700 @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(libpst,0.6.75,carl@five-ten-sg.com) +AC_INIT(libpst,0.6.76,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([src/libpst.c]) AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) @@ -21,7 +21,7 @@ # 6. libtool will build libpst.so.x.y.z where the SONAME is libpst.so.x # and x=current-age, y=age, z=revision -libpst_version_info='5:17:1' +libpst_version_info='5:18:1' AC_SUBST(LIBPST_VERSION_INFO, [$libpst_version_info]) libpst_so_major='4' AC_SUBST(LIBPST_SO_MAJOR, [$libpst_so_major]) @@ -57,6 +57,7 @@ # 0.6.73 libpst.so.4 libpst.so.4.1.15 # 0.6.74 libpst.so.4 libpst.so.4.1.16 # 0.6.75 libpst.so.4 libpst.so.4.1.17 +# 0.6.76 libpst.so.4 libpst.so.4.1.18 diff -r 7200790e46ac -r 24871e6cdd69 libpst.spec.in --- a/libpst.spec.in Tue Jun 16 17:18:28 2020 -0700 +++ b/libpst.spec.in Sat Mar 27 14:53:01 2021 -0700 @@ -1,3 +1,17 @@ +%if "%{?dist}" == ".el8" + %define fedora 32 +%endif + +%if 0%{?fedora} > 27 || 0%{?rhel} >= 9 +%global use_python3 1 +%define __python %{__python3} +%endif + +%if 0%{?rhel} >= 9 +%global with_dii 0 +%else +%global with_dii 1 +%endif Summary: Utilities to convert Outlook .pst files to other formats Name: @PACKAGE@ Version: @VERSION@ @@ -6,37 +20,45 @@ URL: http://www.five-ten-sg.com/%{name}/ Source: %{url}/packages/%{name}-%{version}.tar.gz +BuildRequires: make BuildRequires: libtool gcc-c++ -BuildRequires: ImageMagick gd-devel zlib-devel boost-devel libgsf-devel gettext-devel +BuildRequires: gd-devel zlib-devel boost-devel libgsf-devel gettext-devel -%if "%{?dist}" == ".el8" - %define fedora 32 +%if 0%{with_dii} +BuildRequires: ImageMagick %endif -%if 0%{?fedora} > 27 + +%if 0%{?use_python3} BuildRequires: python3 python3-devel boost-python3 boost-python3-devel Requires: boost-python3 %else BuildRequires: python-devel %endif -Requires: ImageMagick%{?_isa} libgsf gettext +Requires: libgsf gettext Requires: %{name}-libs%{?_isa} = %{version}-%{release} -%if "%{?dist}" == ".el8" - %define __python /usr/bin/python3 - %{!?python_sitelib: %global python_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} - %{!?python_sitearch: %global python_sitearch %(python3 -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} -%else - %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} - %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} +%if 0%{with_dii} +Requires: ImageMagick%{?_isa} %endif +%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} +%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} + + +%if 0%{with_dii} %description The Libpst utilities include readpst which can convert email messages to both mbox and MH mailbox formats, pst2ldif which can convert the contacts to .ldif format for import into ldap databases, and pst2dii which can convert email messages to the DII load file format used by Summation. +%else +%description +The Libpst utilities include readpst which can convert email messages +to both mbox and MH mailbox formats, pst2ldif which can convert the +contacts to .ldif format for import into ldap databases. +%endif %package libs @@ -47,7 +69,7 @@ utilities. -%if 0%{?fedora} > 27 +%if 0%{?use_python3} %package -n python3-%{name} Requires: python3 Provides: %{name}-python = %{version}-%{release} @@ -58,7 +80,7 @@ Summary: Python bindings for libpst Requires: %{name}-libs%{?_isa} = %{version}-%{release} -%if 0%{?fedora} >= 20 +%if 0%{?fedora} >= 20 || 0%{?rhel} >= 9 %global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{python_sitearch}/_.*\.so$ %else %{?filter_setup: @@ -68,7 +90,7 @@ %endif -%if 0%{?fedora} > 27 +%if 0%{?use_python3} %description -n python3-%{name} %else %description python @@ -115,8 +137,13 @@ %build autoreconf -fiv %configure --enable-libpst-shared \ +%if 0%{with_dii} + --enable-dii \ +%else + --disable-dii \ +%endif --with-boost-python=boost_python%{python3_version_nodots} -%if 0%{?fedora} > 27 +%if 0%{?use_python3} %make_build %else make %{?_smp_mflags} @@ -124,7 +151,7 @@ %install -%if 0%{?fedora} > 27 +%if 0%{?use_python3} %make_install %else rm -rf $RPM_BUILD_ROOT @@ -134,8 +161,12 @@ find %{buildroot} -name '*.la' -or -name '*.a' | xargs rm -f mv %{buildroot}%{_datadir}/doc/%{name}-%{version} %{buildroot}%{_datadir}/doc/%{name} +# Remove pst2dii man page, when it's not built +%if !0%{with_dii} +rm %{buildroot}%{_mandir}/man1/pst2dii.1* +%endif -%if 0%{?fedora} > 27 +%if 0%{?use_python3} %ldconfig_scriptlets libs %else %post libs -p /sbin/ldconfig @@ -153,7 +184,7 @@ %doc COPYING -%if 0%{?fedora} > 27 +%if 0%{?use_python3} %files -n python3-%{name} %defattr(-,root,root,-) %{python3_sitearch}/_*.so @@ -184,6 +215,34 @@ %changelog +* Sat Mar 27 2021 Carl Byington 0.6.76-1 +- Stuart C. Naifeh - fix rfc2231 encoding when saving messages to + both .eml and .msg formats. + +* Tue Feb 02 2021 Milan Crha - 0.6.75-9 +- Resolves: #1913613 (Disable DII (and ImageMagic dependency) for RHEL 9) + +* Tue Jan 26 2021 Fedora Release Engineering - 0.6.75-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Fri Jan 22 2021 Jonathan Wakely - 0.6.75-7 +- Rebuilt for Boost 1.75 + +* Tue Jul 28 2020 Merlin Mathesius - 0.6.75-6 +- FTBFS fix: %%{__python} must now be explicitly defined + +* Tue Jul 28 2020 Fedora Release Engineering - 0.6.75-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Thu Jul 16 2020 Merlin Mathesius - 0.6.75-4 +- Cleanup conditionals for using python3 + +* Fri May 29 2020 Jonathan Wakely - 0.6.75-3 +- Rebuilt for Boost 1.73 + +* Tue May 26 2020 Miro HronĨok - 0.6.75-2 +- Rebuilt for Python 3.9 + * Sun Mar 22 2020 Carl Byington 0.6.75-1 - Markus Schnalke - fix from Debian for vcard version format. diff -r 7200790e46ac -r 24871e6cdd69 src/readpst.c --- a/src/readpst.c Tue Jun 16 17:18:28 2020 -0700 +++ b/src/readpst.c Sat Mar 27 14:53:01 2021 -0700 @@ -1179,6 +1179,41 @@ return res; } +/** Convert inp to rfc2231 encoding of string + * + * @param inp pointer to the string of interest + * @return pointer to converted string -- caller must free + */ +char *rfc2231_string(char *inp) { + int needs = 0; + const int8_t *x = (int8_t *)inp; + while (*x) { + if (*x <= 32) needs++; + x++; + } + int n = strlen(inp) + 2*needs + 15; + char *buffer = pst_malloc(n); + strcpy(buffer, "utf-8''"); + x = (int8_t *)inp; + const uint8_t *y = (uint8_t *)inp; + uint8_t *z = (uint8_t *)buffer; + z += strlen(buffer); // skip the utf8 prefix + while (*y) { + if (*x <= 32) { + *(z++) = (uint8_t)'%'; + snprintf(z, 3, "%2x", *y); + z += 2; + } + else { + *(z++) = *y; + } + x++; + y++; + } + *z = '\0'; + return buffer; +} + void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst) { DEBUG_ENT("write_inline_attachment"); @@ -1210,8 +1245,10 @@ // use the long filename, converted to proper encoding if needed. // it is already utf8 char *escaped = quote_string(attach->filename2.str); - pst_rfc2231(&attach->filename2); - fprintf(f_output, "Content-Disposition: attachment; \n filename*=%s;\n", attach->filename2.str); + // encode long filename as rfc2231 without modifying original -- we may still need the original long filename + char *rfc2231 = rfc2231_string(attach->filename2.str); + fprintf(f_output, "Content-Disposition: attachment; \n filename*=%s;\n", rfc2231); + free (rfc2231); // Also include the (escaped) utf8 filename in the 'filename' header directly - this is not strictly valid // (since this header should be ASCII) but is almost always handled correctly (and in fact this is the only // way to get MS Outlook to correctly read a UTF8 filename, AFAICT, which is why we're doing it).