diff --git a/impit-node/src/response.rs b/impit-node/src/response.rs index e1a0ba0d..9959afe6 100644 --- a/impit-node/src/response.rs +++ b/impit-node/src/response.rs @@ -89,6 +89,9 @@ impl<'env> ImpitResponse { .canonical_reason() .unwrap_or("") .to_string(); + // JS Fetch semantics: header values are decoded as ISO-8859-1 (each byte 0x00..=0xFF maps to + // the code point U+0000..=U+00FF). Since that mapping is a bijection, the string stays + // byte-recoverable via `Buffer.from(value, 'latin1')`. let mut headers_vec: Vec<(String, String)> = Vec::new(); for (k, v) in response.headers().iter() { headers_vec.push(( diff --git a/impit-node/test/basics.test.ts b/impit-node/test/basics.test.ts index 7f7df808..f009f8cc 100644 --- a/impit-node/test/basics.test.ts +++ b/impit-node/test/basics.test.ts @@ -571,6 +571,18 @@ describe.each([ t.expect(response.headers.get('x-non-ascii')).toBe(routes.nonAsciiHeader.headerValue); }); + test('UTF-8 header values stay ISO-8859-1 and are byte-recoverable (Fetch-style)', async (t) => { + const response = await impit.fetch(new URL(routes.utf8Header.path, "http://127.0.0.1:3001").href); + + // Fetch semantics: the string form is ISO-8859-1, so a UTF-8 value reads back as mojibake. + const latin1 = response.headers.get('x-utf8'); + t.expect(latin1).not.toBe(routes.utf8Header.headerValue); + + // ISO-8859-1 is a bijection, so the exact wire bytes are recoverable, and re-decoding + // as UTF-8 yields the real value — no dedicated raw-header accessor needed. + t.expect(Buffer.from(latin1!, 'latin1').toString('utf8')).toBe(routes.utf8Header.headerValue); + }); + test('.json() method works', async (t) => { const response = await impit.fetch(getHttpBinUrl('/json')); const json = await response.json(); diff --git a/impit-node/test/mock.server.ts b/impit-node/test/mock.server.ts index 3c2ddf6f..1ebba4bb 100644 --- a/impit-node/test/mock.server.ts +++ b/impit-node/test/mock.server.ts @@ -24,6 +24,10 @@ export const routes = { path: '/non-ascii-header', headerValue: 'Dienstag, 31. März 2026', }, + utf8Header: { + path: '/utf8-header', + headerValue: 'attachment; filename="naïve.pdf"', + }, } function parseMultipart(body: Buffer, boundary: string): Record { @@ -117,6 +121,22 @@ export async function runServer(port: number): Promise { socket.end(); }); + app.get(routes.utf8Header.path, (req, res) => { + const socket = res.socket!; + socket.write('HTTP/1.1 200 OK\r\n'); + socket.write('Content-Type: text/plain\r\n'); + // Header value carrying UTF-8 bytes (the ï is 0xC3 0xAF). + socket.write(Buffer.concat([ + Buffer.from('X-Utf8: '), + Buffer.from(routes.utf8Header.headerValue, 'utf-8'), + Buffer.from('\r\n'), + ])); + socket.write('Content-Length: 2\r\n'); + socket.write('\r\n'); + socket.write('ok'); + socket.end(); + }); + app.get('/socket', (req, res) => { const socket = req.socket; const clientAddress = socket.remoteAddress; diff --git a/impit-python/python/impit/__init__.py b/impit-python/python/impit/__init__.py index de7b311c..c09bef40 100644 --- a/impit-python/python/impit/__init__.py +++ b/impit-python/python/impit/__init__.py @@ -2,6 +2,7 @@ from typing import Literal from .cookies import Cookies +from .headers import Headers from .impit import ( USE_CLIENT_DEFAULT, AsyncClient, @@ -61,6 +62,7 @@ 'DecodingError', 'HTTPError', 'HTTPStatusError', + 'Headers', 'InvalidURL', 'LocalProtocolError', 'NetworkError', diff --git a/impit-python/python/impit/headers.py b/impit-python/python/impit/headers.py new file mode 100644 index 00000000..28f505dc --- /dev/null +++ b/impit-python/python/impit/headers.py @@ -0,0 +1,226 @@ +"""Copyright © 2019, [Encode OSS Ltd](https://www.encode.io/). + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" +# ruff: noqa: D102, D105, E501, FBT001, FBT002, PERF203, PLW1641, SIM118, SLF001 + +## The Headers class below is a modification of the `httpx.Headers` class, licensed under the BSD 3-Clause "New" License. + +from __future__ import annotations + +import typing +from collections.abc import Mapping + +HeaderTypes = typing.Union[ + 'Headers', + typing.Mapping[str, str], + typing.Mapping[bytes, bytes], + typing.Sequence[tuple[str, str]], + typing.Sequence[tuple[bytes, bytes]], +] + +SENSITIVE_HEADERS = {'authorization', 'proxy-authorization'} + + +def _normalize_header_key(key: str | bytes, encoding: str | None = None) -> bytes: + return key if isinstance(key, bytes) else key.encode(encoding or 'ascii') + + +def _normalize_header_value(value: str | bytes, encoding: str | None = None) -> bytes: + return value if isinstance(value, bytes) else value.encode(encoding or 'ascii') + + +def _obfuscate_sensitive_headers( + items: typing.Iterable[tuple[str, str]], +) -> typing.Iterator[tuple[str, str]]: + for k, v in items: + yield k, ('[secure]' if k.lower() in SENSITIVE_HEADERS else v) + + +class Headers(typing.MutableMapping[str, str]): + """HTTP headers, as a case-insensitive multi-dict. + + Mirrors the `httpx.Headers` interface, including the `raw` property that exposes the exact + header value bytes received on the wire. + """ + + def __init__(self, headers: HeaderTypes | None = None, encoding: str | None = None) -> None: + self._list: list[tuple[bytes, bytes, bytes]] = [] + + if isinstance(headers, Headers): + self._list = list(headers._list) + elif isinstance(headers, Mapping): + for k, v in headers.items(): + bytes_key = _normalize_header_key(k, encoding) + bytes_value = _normalize_header_value(v, encoding) + self._list.append((bytes_key, bytes_key.lower(), bytes_value)) + elif headers is not None: + for k, v in headers: + bytes_key = _normalize_header_key(k, encoding) + bytes_value = _normalize_header_value(v, encoding) + self._list.append((bytes_key, bytes_key.lower(), bytes_value)) + + self._encoding = encoding + + @property + def encoding(self) -> str: + """Header encoding is mandated as ascii, but we allow fallbacks to utf-8 or iso-8859-1.""" + if self._encoding is None: + for encoding in ['ascii', 'utf-8']: + for key, value in self.raw: + try: + key.decode(encoding) + value.decode(encoding) + except UnicodeDecodeError: + break + else: + self._encoding = encoding + break + else: + # ISO-8859-1 covers all 256 byte values, so it never raises decode errors. + self._encoding = 'iso-8859-1' + return self._encoding + + @encoding.setter + def encoding(self, value: str) -> None: + self._encoding = value + + @property + def raw(self) -> list[tuple[bytes, bytes]]: + """Return the raw header items, as `(name, value)` byte pairs.""" + return [(raw_key, value) for raw_key, _, value in self._list] + + def keys(self) -> typing.KeysView[str]: + return {key.decode(self.encoding): None for _, key, value in self._list}.keys() + + def values(self) -> typing.ValuesView[str]: + values_dict: dict[str, str] = {} + for _, key, value in self._list: + str_key = key.decode(self.encoding) + str_value = value.decode(self.encoding) + if str_key in values_dict: + values_dict[str_key] += f', {str_value}' + else: + values_dict[str_key] = str_value + return values_dict.values() + + def items(self) -> typing.ItemsView[str, str]: + """Return `(key, value)` items, concatenating repeated keys with commas.""" + values_dict: dict[str, str] = {} + for _, key, value in self._list: + str_key = key.decode(self.encoding) + str_value = value.decode(self.encoding) + if str_key in values_dict: + values_dict[str_key] += f', {str_value}' + else: + values_dict[str_key] = str_value + return values_dict.items() + + def multi_items(self) -> list[tuple[str, str]]: + """Return `(key, value)` pairs without concatenating repeated keys.""" + return [(key.decode(self.encoding), value.decode(self.encoding)) for _, key, value in self._list] + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """Return a header value, concatenating repeated occurrences with commas.""" + try: + return self[key] + except KeyError: + return default + + def get_list(self, key: str, split_commas: bool = False) -> list[str]: + """Return all header values for `key`, optionally splitting on commas.""" + get_header_key = key.lower().encode(self.encoding) + values = [ + item_value.decode(self.encoding) + for _, item_key, item_value in self._list + if item_key.lower() == get_header_key + ] + if not split_commas: + return values + split_values = [] + for value in values: + split_values.extend([item.strip() for item in value.split(',')]) + return split_values + + def update(self, headers: HeaderTypes | None = None) -> None: # type: ignore[override] + headers = Headers(headers) + for key in headers.keys(): + if key in self: + self.pop(key) + self._list.extend(headers._list) + + def copy(self) -> Headers: + return Headers(self, encoding=self.encoding) + + def __getitem__(self, key: str) -> str: + """Return a single header value; repeated keys are joined with commas (RFC 7230 §3.2.2).""" + normalized_key = key.lower().encode(self.encoding) + items = [ + header_value.decode(self.encoding) + for _, header_key, header_value in self._list + if header_key == normalized_key + ] + if items: + return ', '.join(items) + raise KeyError(key) + + def __setitem__(self, key: str, value: str) -> None: + """Set `key` to `value`, removing duplicates and retaining insertion order.""" + set_key = key.encode(self._encoding or 'utf-8') + set_value = value.encode(self._encoding or 'utf-8') + lookup_key = set_key.lower() + found_indexes = [idx for idx, (_, item_key, _) in enumerate(self._list) if item_key == lookup_key] + for idx in reversed(found_indexes[1:]): + del self._list[idx] + if found_indexes: + idx = found_indexes[0] + self._list[idx] = (set_key, lookup_key, set_value) + else: + self._list.append((set_key, lookup_key, set_value)) + + def __delitem__(self, key: str) -> None: + """Remove the header `key`.""" + del_key = key.lower().encode(self.encoding) + pop_indexes = [idx for idx, (_, item_key, _) in enumerate(self._list) if item_key.lower() == del_key] + if not pop_indexes: + raise KeyError(key) + for idx in reversed(pop_indexes): + del self._list[idx] + + def __contains__(self, key: typing.Any) -> bool: + header_key = key.lower().encode(self.encoding) + return header_key in [key for _, key, _ in self._list] + + def __iter__(self) -> typing.Iterator[typing.Any]: + return iter(self.keys()) + + def __len__(self) -> int: + return len(self._list) + + def __eq__(self, other: object) -> bool: + try: + other_headers = Headers(other) # type: ignore[arg-type] + except ValueError: + return False + self_list = [(key, value) for _, key, value in self._list] + other_list = [(key, value) for _, key, value in other_headers._list] + return sorted(self_list) == sorted(other_list) + + def __repr__(self) -> str: + class_name = self.__class__.__name__ + encoding_str = f', encoding={self.encoding!r}' if self.encoding != 'ascii' else '' + as_list = list(_obfuscate_sensitive_headers(self.multi_items())) + as_dict = dict(as_list) + if len(as_dict) == len(as_list): + return f'{class_name}({as_dict!r}{encoding_str})' + return f'{class_name}({as_list!r}{encoding_str})' diff --git a/impit-python/python/impit/impit.pyi b/impit-python/python/impit/impit.pyi index 7be1fbf1..88d9a395 100644 --- a/impit-python/python/impit/impit.pyi +++ b/impit-python/python/impit/impit.pyi @@ -1,6 +1,7 @@ from __future__ import annotations from http.cookiejar import CookieJar from .cookies import Cookies +from .headers import Headers from typing import Literal, Any from collections.abc import Iterator, AsyncIterator @@ -171,13 +172,20 @@ class Response: print(response.http_version) # 'HTTP/2' """ - headers: dict[str, str] - """Response headers as a Python dictionary. + headers: Headers + """Response headers as an httpx-style :class:`Headers` object. + + Provides case-insensitive ``str`` access, plus a ``.raw`` property exposing the exact header + value bytes received on the wire (useful for UTF-8 header values or signature/HMAC checks). + + This is a read view: each access rebuilds the object from the response, so in-place mutations + (``response.headers['x'] = ...``) do not persist on the response. .. code-block:: python response = await client.get("https://crawlee.dev") - print(response.headers) # {'content-type': 'text/html; charset=utf-8', ... } + print(response.headers['content-type']) # 'text/html; charset=utf-8' + print(response.headers.raw) # [(b'content-type', b'text/html; charset=utf-8'), ... ] """ text: str diff --git a/impit-python/src/response.rs b/impit-python/src/response.rs index a5cb5a15..803d5930 100644 --- a/impit-python/src/response.rs +++ b/impit-python/src/response.rs @@ -7,6 +7,7 @@ use encoding::label::encoding_from_whatwg_label; use futures::{Stream, StreamExt}; use impit::{errors::ImpitError, utils::ContentType}; use pyo3::prelude::*; +use pyo3::types::PyBytes; use reqwest::{Response, StatusCode, Version}; use std::pin::Pin; @@ -198,8 +199,6 @@ pub struct ImpitPyResponse { #[pyo3(get)] http_version: String, #[pyo3(get)] - headers: HashMap, - #[pyo3(get)] encoding: String, #[pyo3(get)] is_redirect: bool, @@ -223,6 +222,9 @@ pub struct ImpitPyResponse { content: Option>, inner: Option, inner_state: InnerResponseState, + // Raw, undecoded header name/value byte pairs. The `headers` getter builds the Python-side + // `Headers` object (httpx-style: str access + `.raw`) from these exact wire bytes. + raw_headers: Vec<(Vec, Vec)>, } #[pymethods] @@ -238,6 +240,12 @@ impl ImpitPyResponse { ) -> Self { let headers = headers.unwrap_or_default(); + // No wire bytes for a manually constructed response; use the UTF-8 bytes of the strings. + let raw_headers: Vec<(Vec, Vec)> = headers + .iter() + .map(|(k, v)| (k.clone().into_bytes(), v.clone().into_bytes())) + .collect(); + let encoding = match headers .iter() .find(|(k, _)| k.to_lowercase() == "content-type") @@ -257,7 +265,6 @@ impl ImpitPyResponse { status_code, reason_phrase, http_version: "HTTP/1.1".to_string(), - headers, encoding, is_redirect: false, url: url.unwrap_or_default(), @@ -267,6 +274,7 @@ impl ImpitPyResponse { content: Some(content.unwrap_or_default()), inner: None, inner_state: InnerResponseState::Read, + raw_headers, } } @@ -439,6 +447,24 @@ impl ImpitPyResponse { Ok(()) } + /// Response headers as an httpx-style [`Headers`] object: case-insensitive `str` access plus a + /// `.raw` property exposing the exact header value bytes received on the wire (useful for UTF-8 + /// values or header signature/HMAC verification). Built from the raw wire bytes; `Headers` + /// itself picks the decoding (ascii, then utf-8, then iso-8859-1), matching httpx. + /// + /// Read view: each access rebuilds the object, so in-place mutations do not persist. + #[getter] + fn headers<'py>(&self, py: Python<'py>) -> PyResult> { + let raw: Vec<(Bound<'py, PyBytes>, Bound<'py, PyBytes>)> = self + .raw_headers + .iter() + .map(|(name, value)| (PyBytes::new(py, name), PyBytes::new(py, value))) + .collect(); + py.import("impit.headers")? + .getattr("Headers")? + .call1((raw,)) + } + #[getter] fn content(&mut self, py: Python<'_>) -> PyResult> { self.read(py) @@ -536,16 +562,21 @@ impl ImpitPyResponse { _ => "Unknown".to_string(), }; let is_redirect = val.status().is_redirection(); - let headers = HashMap::from_iter(val.headers().iter().map(|(k, v)| { - ( - k.as_str().to_string(), - v.as_bytes().iter().map(|&b| b as char).collect::(), - ) - })); + // Exact wire header bytes; the Python `Headers` object (str access + `.raw`) is built from + // these, and it — not Rust — chooses the decoding (ascii/utf-8/iso-8859-1), matching httpx. + let raw_headers: Vec<(Vec, Vec)> = val + .headers() + .iter() + .map(|(k, v)| (k.as_str().as_bytes().to_vec(), v.as_bytes().to_vec())) + .collect(); - let content_type_charset = headers + // Charset detection only needs the content-type value, which is ASCII per RFC 9110 + // (media type + charset are tokens), so a lossy UTF-8 decode is sufficient. + let content_type_charset = val + .headers() .get("content-type") - .and_then(|ct| ContentType::from(ct).ok()) + .map(|v| String::from_utf8_lossy(v.as_bytes()).into_owned()) + .and_then(|ct| ContentType::from(&ct).ok()) .and_then(|ct| ct.into()); let (content, inner_state, encoding, inner, is_closed, is_stream_consumed) = if !stream { @@ -589,7 +620,6 @@ impl ImpitPyResponse { reason_phrase, http_version, is_redirect, - headers, encoding: encoding.name().to_string(), text: None, content, @@ -597,6 +627,7 @@ impl ImpitPyResponse { is_stream_consumed, inner_state, inner, + raw_headers, }) } } diff --git a/impit-python/test/async_client_test.py b/impit-python/test/async_client_test.py index 8a0b11b5..96d6a552 100644 --- a/impit-python/test/async_client_test.py +++ b/impit-python/test/async_client_test.py @@ -46,6 +46,36 @@ def truncating_server(port_holder: list[int]) -> None: server.close() +def header_encoding_server(port_holder: list[int]) -> None: + """Send a response carrying a UTF-8 header value on the wire.""" + server = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) + server.bind(('::', 0)) + port_holder[0] = server.getsockname()[1] + server.listen(1) + + conn, _ = server.accept() + conn.recv(1024) + body = b'ok' + response = b''.join( + [ + b'HTTP/1.1 200 OK\r\n', + b'Content-Type: text/plain\r\n', + b'X-Utf8: ', + 'attachment; filename="naïve.pdf"'.encode(), + b'\r\n', + b'Content-Length: ', + str(len(body)).encode(), + b'\r\n\r\n', + body, + ] + ) + conn.send(response) + conn.close() + server.close() + + @pytest.mark.asyncio @pytest.mark.parametrize( ('browser', 'ja4'), @@ -425,6 +455,26 @@ async def test_local_address(self, browser: Browser, addresses: tuple[str, str]) assert response.status_code == 200 thread.join() + @pytest.mark.asyncio + async def test_header_value_decoding_and_raw_bytes(self, browser: Browser) -> None: + port_holder = [0] + thread = threading.Thread(target=header_encoding_server, args=(port_holder,)) + thread.start() + await asyncio.sleep(0.1) + + impit = AsyncClient(browser=browser) + response = await impit.get(f'http://127.0.0.1:{port_holder[0]}/', timeout=5) + thread.join() + + utf8_value = 'attachment; filename="naïve.pdf"' + + # httpx semantics: with only ASCII/UTF-8 headers present, the chosen encoding is utf-8, so + # the UTF-8 header value decodes correctly as str. + assert response.headers.encoding == 'utf-8' + assert response.headers['x-utf8'] == utf8_value + # Headers.raw exposes the exact wire bytes. + assert dict(response.headers.raw)[b'x-utf8'] == utf8_value.encode('utf-8') + @pytest.mark.parametrize( ('browser'), diff --git a/impit-python/test/headers_test.py b/impit-python/test/headers_test.py new file mode 100644 index 00000000..b1488312 --- /dev/null +++ b/impit-python/test/headers_test.py @@ -0,0 +1,51 @@ +from impit import Headers + + +def test_raw_exposes_exact_wire_bytes() -> None: + utf8 = 'attachment; filename="naïve.pdf"' + headers = Headers([(b'content-type', b'text/plain'), (b'x-utf8', utf8.encode('utf-8'))]) + + assert headers.raw == [(b'content-type', b'text/plain'), (b'x-utf8', utf8.encode('utf-8'))] + + +def test_utf8_only_headers_decode_as_utf8() -> None: + utf8 = 'attachment; filename="naïve.pdf"' + headers = Headers([(b'x-utf8', utf8.encode('utf-8'))]) + + assert headers.encoding == 'utf-8' + assert headers['x-utf8'] == utf8 + + +def test_invalid_utf8_falls_back_to_iso_8859_1() -> None: + # A lone 0xE4 ('ä') is not valid UTF-8, so the whole set decodes as ISO-8859-1 (httpx behavior). + headers = Headers([(b'x-latin1', b'M\xe4rz')]) + + assert headers.encoding == 'iso-8859-1' + assert headers['x-latin1'] == 'März' + + +def test_ascii_headers_use_ascii_encoding() -> None: + assert Headers([(b'a', b'b')]).encoding == 'ascii' + + +def test_case_insensitive_access() -> None: + headers = Headers([(b'Content-Type', b'application/json')]) + + assert headers['content-type'] == 'application/json' + assert headers['CONTENT-TYPE'] == 'application/json' + assert 'Content-Type' in headers + assert headers.get('missing', 'default') == 'default' + + +def test_repeated_keys_join_and_list() -> None: + headers = Headers([(b'set-cookie', b'a=1'), (b'set-cookie', b'b=2')]) + + assert headers['set-cookie'] == 'a=1, b=2' + assert headers.get_list('set-cookie') == ['a=1', 'b=2'] + + +def test_construct_from_str_mapping() -> None: + headers = Headers({'Content-Type': 'application/json'}) + + assert headers['content-type'] == 'application/json' + assert headers.raw == [(b'Content-Type', b'application/json')] diff --git a/impit-python/test/response_test.py b/impit-python/test/response_test.py index ba09610f..0d52ffd2 100644 --- a/impit-python/test/response_test.py +++ b/impit-python/test/response_test.py @@ -40,6 +40,21 @@ def test_response_constructor_with_headers() -> None: assert response.headers['Content-Type'] == 'application/json' +def test_response_headers_raw() -> None: + # response.headers is an httpx-style Headers object exposing exact bytes via `.raw`. + response = Response(200, headers={'Content-Type': 'application/json', 'X-Unicode': 'naïve'}) + + raw = response.headers.raw + + assert isinstance(raw, list) + assert all(isinstance(k, bytes) and isinstance(v, bytes) for k, v in raw) + assert (b'Content-Type', b'application/json') in raw + # A non-ASCII value is preserved as its exact UTF-8 bytes. + assert (b'X-Unicode', 'naïve'.encode()) in raw + # Case-insensitive str access still works. + assert response.headers['content-type'] == 'application/json' + + def test_response_headers_encoding() -> None: response = Response( 200, headers={'Content-Type': 'text/plain; charset=cp1250'}, content=b'\x9e\x64\xe1\xf8\x65\x6e\xed'