Deutsch English Français Italiano |
<mailman.52.1736192610.2912.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!npeer.as286.net!npeer-ng0.as286.net!fu-berlin.de!uni-berlin.de!not-for-mail From: "Peter J. Holzer" <hjp-python@hjp.at> Newsgroups: comp.lang.python Subject: Re: How to manage accented characters in mail header? Date: Mon, 6 Jan 2025 20:43:21 +0100 Lines: 58 Message-ID: <mailman.52.1736192610.2912.python-list@python.org> References: <satn4l-6sqh.ln1@q957.zbmc.eu> <decode_header-20250104154914@ram.dialup.fu-berlin.de> <dhdo4l-uvsi.ln1@q957.zbmc.eu> <20250106194321.oz27jt37xpuhdssn@hjp.at> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="e7ytifu4m7upqtfl" X-Trace: news.uni-berlin.de cBdVP93fFSUaivD5Qav+Pwt0VTtBMpDs8HCF3uPoNiDw== Cancel-Lock: sha1:gRItGcyjw+aVXJEj4e+CFD36xfo= sha256:kPwhZ6+rpfMJhr5kkQuZFK0oQPdh/bODTze9n4wNBBw= Return-Path: <hjp-python@hjp.at> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'content- type:multipart/signed': 0.05; 'ram': 0.07; '<>,': 0.09; 'content- type:application/pgp-signature': 0.09; 'filename:fname piece:asc': 0.09; 'filename:fname piece:signature': 0.09; 'filename:fname:signature.asc': 0.09; 'subject:header': 0.09; '"creative': 0.16; '__/': 0.16; 'challenge!"': 0.16; 'encoded,': 0.16; 'from:addr:hjp-python': 0.16; 'from:addr:hjp.at': 0.16; 'from:name:peter j. holzer': 0.16; 'hjp@hjp.at': 0.16; 'holzer': 0.16; 'parsing': 0.16; 'reality.': 0.16; 'stross,': 0.16; 'subject:characters': 0.16; 'url-ip:212.17.106.129/32': 0.16; 'url-ip:212.17.106/24': 0.16; 'url-ip:212.17/16': 0.16; 'url:hjp': 0.16; '|_|_)': 0.16; 'wrote:': 0.16; 'addresses': 0.19; 'it?': 0.19; 'to:addr:python-list': 0.20; 'header': 0.23; 'stefan': 0.26; 'chris': 0.28; 'sense': 0.28; 'think': 0.29; 'subject:How': 0.31; "doesn't": 0.32; 'extract': 0.32; 'python-list': 0.32; 'there': 0.33; 'header:In-Reply-To:1': 0.34; 'also,': 0.36; 'way': 0.38; 'use': 0.39; "that's": 0.39; 'wrote': 0.39; 'email': 0.63; 'between': 0.63; 'from:': 0.63; 'received:userid': 0.66; 'skip:e 20': 0.67; 'latter': 0.69; 'charset:iso-8859-1': 0.73; 'supposed': 0.76; 'need.': 0.84; 'decode': 0.84; 'received:at': 0.84; 'subject:mail': 0.95; 'green': 0.96 Mail-Followup-To: python-list@python.org Content-Disposition: inline In-Reply-To: <dhdo4l-uvsi.ln1@q957.zbmc.eu> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: General discussion list for the Python programming language <python-list.python.org> List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> List-Archive: <https://mail.python.org/pipermail/python-list/> List-Post: <mailto:python-list@python.org> List-Help: <mailto:python-list-request@python.org?subject=help> List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> X-Mailman-Original-Message-ID: <20250106194321.oz27jt37xpuhdssn@hjp.at> X-Mailman-Original-References: <satn4l-6sqh.ln1@q957.zbmc.eu> <decode_header-20250104154914@ram.dialup.fu-berlin.de> <dhdo4l-uvsi.ln1@q957.zbmc.eu> Bytes: 5794 --e7ytifu4m7upqtfl Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2025-01-04 19:07:57 +0000, Chris Green via Python-list wrote: > Stefan Ram <ram@zedat.fu-berlin.de> wrote: > > Chris Green <cl@isbd.net> wrote or quoted: > > >From: =3D?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?=3D <sebastien.crignon@amvs= =2Efr> > >=20 > Is there a simple[r] way to extract just the 'real' address between > the <>, that's all I actually need. I think it has the be the last > chunk of the From: doesn't it? No, From: <sebastien.crignon@amvs.fr> (S=E9bastien Crignon) would also be permissible (properly encoded, of course), and even From: < sebastien (S=E9bastien) . crignon (Crignon) @ amvs . fr > (although I think the latter is deprecated). And also, there can be more than one address in a From header. To properly extract email addresses from a header, use email.utils.getaddresses(). You don't have to decode the header first. The MIME-encoding is supposed to not interfere with parsing headers for machine-readable information like addresses or message ids. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --e7ytifu4m7upqtfl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmd8MlMACgkQ8g5IURL+ KF0cpRAApcdq2w7t5+wi7xUEpTpJoZvoW7VbuAfm5LUh5YKYZImjrAyZf7o7t02S wAFyUSEqr5UmcDYE3Fvg2zizYi8ua1QTKIJbLfR88qwTGOHkLDfu0bVn7DvvEiTW 5dlU6ykxFUk7YeNtdBgtmiaUNi5iuONrDcWK+ddFm4oyDesCcaTnLlqIQnR524kU xord18YoGwMDxI+LAXeMNgX/tndqh3339r6Av/UwLq96O+1e+lHOC1bUKYng+Pwm IdeZEfHJMFKvylTV2tqh5zhut3g9F3WiWAoC0Gr5Ib3tIoKXXA1KPwSpHBSzNqP0 tEfi5KIOmScbCtd8vIlE0Qpkg+4Z3Eb7RGWsxMiuk/KGxblHBxkKgBrAkLJSY1Sd PT9YnU/6h/z1i6x4Rp34zXfdg+yfN3nO1DqRK17bWvvCKIiNvT5G4JldgAcSme8L QgQdY8Ls1keGUSggy35xYkpLxzafFFc0uZuFzJrm1oVXb0NKcldyiMJDAqegnaMR wTueBj2QFTJYZqrAlHgUyGzOnP4HZxTfYwyynoFkuzQpDrla3QHnjUFFAIz6mv0W CVBVo48wPuyiqgPU/UgWb1sQZ2YDv+pFmlUJUqpbUC+H3JrWU7wg9rljIU218HYn /6pSzIwEIuscCji4iVCZXIVXaWI8XqQqO0BqjJuhCJfGnFSC0jE= =ooym -----END PGP SIGNATURE----- --e7ytifu4m7upqtfl--