~garritfra/taurus

taurus: Cancel request on invalid Unicode character v1 PROPOSED

Alexey Yerin: 1
 Cancel request on invalid Unicode character

 2 files changed, 4 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~garritfra/taurus/patches/15331/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH taurus] Cancel request on invalid Unicode character Export this patch

It's pointless to continue as file names mostly don't contain invalid
Unicode.

Signed-off-by: Alexey Yerin <yerinalexey98fd@gmail.com>
---
 src/error.rs | 3 +++
 src/main.rs  | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/error.rs b/src/error.rs
index f2910be..2e2fc71 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -17,6 +17,9 @@ pub enum TaurusError {
    #[error("invalid request: {0}")]
    InvalidRequest(String),

    #[error("invalid Unicode character in the input")]
    InvalidUnicode(#[from] std::string::FromUtf8Error),

    #[error("failed to bind: {0}")]
    BindFailed(io::Error),

diff --git a/src/main.rs b/src/main.rs
index 4a48340..9524434 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -99,7 +99,7 @@ fn handle_client(mut stream: TlsStream<TcpStream>, static_root: &str) -> TaurusR
        .read(&mut buffer)
        .map_err(TaurusError::StreamReadFailed)?;

    let raw_request = String::from_utf8_lossy(&buffer[..]).into_owned();
    let raw_request = String::from_utf8(buffer.to_vec())?;

    let request = GeminiRequest::parse(&raw_request)?;
    let url_path = request.file_path();
-- 
2.29.2