From 407fadb8171fd2435792ed4d5a066012a48f1dbd Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 5 Feb 2025 12:48:30 +0100 Subject: [PATCH] :bug: fix handling of invalid IDNA labels --- CHANGELOG.rst | 6 ++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- qh3/__init__.py | 2 +- src/intldomain.rs | 7 +++---- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e2db064d..305705ba 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,9 @@ +1.4.1 (2025-02-05) +==================== + +**Fixed** +- Bad IDNA label raise inappropriate exception. + 1.4.0 (2025-02-05) ==================== diff --git a/Cargo.lock b/Cargo.lock index 9e08e23b..add240de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1122,7 +1122,7 @@ dependencies = [ [[package]] name = "qh3" -version = "1.4.0" +version = "1.4.1" dependencies = [ "aws-lc-rs", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 2278d2de..36687a3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "qh3" -version = "1.4.0" +version = "1.4.1" edition = "2021" rust-version = "1.75" license = "BSD-3" diff --git a/qh3/__init__.py b/qh3/__init__.py index 07df4d06..47c27211 100644 --- a/qh3/__init__.py +++ b/qh3/__init__.py @@ -13,7 +13,7 @@ from .quic.packet import QuicProtocolVersion from .tls import CipherSuite, SessionTicket -__version__ = "1.4.0" +__version__ = "1.4.1" __all__ = ( "connect", diff --git a/src/intldomain.rs b/src/intldomain.rs index 1ebab966..fd8fcf61 100644 --- a/src/intldomain.rs +++ b/src/intldomain.rs @@ -1,5 +1,4 @@ -use pyo3::exceptions::PyUnicodeDecodeError; -use pyo3::exceptions::PyUnicodeEncodeError; +use pyo3::exceptions::PyValueError; use pyo3::pyfunction; use pyo3::types::PyBytesMethods; use pyo3::types::{PyBytes, PyString}; @@ -13,7 +12,7 @@ use idna::domain_to_unicode; pub fn idna_encode<'a>(py: Python<'a>, text: &str) -> PyResult> { let idna_domain = match domain_to_ascii(text) { Ok(s) => s, - Err(e) => return Err(PyUnicodeEncodeError::new_err(e.to_string())), + Err(e) => return Err(PyValueError::new_err(e.to_string())), }; Ok(PyBytes::new(py, idna_domain.as_bytes())) @@ -24,7 +23,7 @@ pub fn idna_decode<'a>(py: Python<'a>, src: Bound<'a, PyBytes>) -> PyResult