~garritfra/taurus

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH taurus] Cancel request on invalid Unicode character

Details
Message ID
<20201126205821.80929-1-yerinalexey98fd@gmail.com>
DKIM signature
pass
Download raw message
Patch: +4 -1
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
Details
Message ID
<CAD16O84JtDBeDRhuEOQs2pobQ17EfBrMs5V6-RTdQzvP4ejV4g@mail.gmail.com>
In-Reply-To
<20201126205821.80929-1-yerinalexey98fd@gmail.com> (view parent)
DKIM signature
pass
Download raw message
> +    #[error("invalid Unicode character in the input")]
> +    InvalidUnicode(#[from] std::string::FromUtf8Error),

Why do you add this error if you never call it?
Details
Message ID
<20201127134256.sbmxgymtyrji5qb5@arch>
In-Reply-To
<CAD16O84JtDBeDRhuEOQs2pobQ17EfBrMs5V6-RTdQzvP4ejV4g@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
> Why do you add this error if you never call it?

Because FromUtf8Error converts to it when used with `?`.
Details
Message ID
<CAD16O87nckgj-YAND7JEV3d2eb_=M7nbkEVBRCQ+k2UP-bw8Bw@mail.gmail.com>
In-Reply-To
<20201127134256.sbmxgymtyrji5qb5@arch> (view parent)
DKIM signature
pass
Download raw message
> Because FromUtf8Error converts to it when used with `?`.

Oh, right. I should read the entire code, instead of just the gist.

Applied!
Reply to thread Export thread (mbox)