From 35c6a80e95ca3d29749203c601182f07f80d19a7 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Wed, 24 Jan 2024 17:04:32 +0100 Subject: Add debug log for mime type validation --- rs/server/src/main.rs | 12 ++++++++++++ rs/shell/src/main.rs | 10 +++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'rs') diff --git a/rs/server/src/main.rs b/rs/server/src/main.rs index 2051b62..7060b15 100644 --- a/rs/server/src/main.rs +++ b/rs/server/src/main.rs @@ -299,6 +299,18 @@ fn is_git_lfs_json_mimetype(mimetype: &str) -> bool { let Ok(mime) = mimetype.parse::() else { return false; }; + println!( + "MIME type: {:?}; type: {}, subtype: {}, suffix: {}, charset: {}", + mime, + mime.type_(), + mime.subtype(), + mime.suffix() + .map(|name| name.to_string()) + .unwrap_or("".to_string()), + mime.get_param(mime::CHARSET) + .map(|name| name.to_string()) + .unwrap_or("".to_string()) + ); if mime.type_() != mime::APPLICATION || mime.subtype() != "vnd.git-lfs" || mime.suffix() != Some(mime::JSON) diff --git a/rs/shell/src/main.rs b/rs/shell/src/main.rs index b9c50d8..ef0ef48 100644 --- a/rs/shell/src/main.rs +++ b/rs/shell/src/main.rs @@ -1,4 +1,4 @@ -use std::{process::ExitCode, os::unix::process::CommandExt}; +use std::{os::unix::process::CommandExt, process::ExitCode}; fn parse_sq(s: &str) -> Option<(String, &str)> { #[derive(PartialEq, Eq)] @@ -7,13 +7,13 @@ fn parse_sq(s: &str) -> Option<(String, &str)> { Unquoted { may_escape: bool }, UnquotedEscaped, } - + let mut result = String::new(); let mut state = SqState::Unquoted { may_escape: false }; let mut remaining = ""; for (i, c) in s.char_indices() { match state { - SqState::Unquoted { may_escape: false} => { + SqState::Unquoted { may_escape: false } => { if c != '\'' { return None; } @@ -26,7 +26,7 @@ fn parse_sq(s: &str) -> Option<(String, &str)> { } result.push(c); } - SqState::Unquoted { may_escape: true }=> { + SqState::Unquoted { may_escape: true } => { if is_posix_space(c) { remaining = &s[i..]; break; @@ -47,7 +47,7 @@ fn parse_sq(s: &str) -> Option<(String, &str)> { } if state != (SqState::Unquoted { may_escape: true }) { - return None + return None; } Some((result, remaining)) } -- cgit v1.2.3