Skip to content

Commit

Permalink
Improve subject validation
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <[email protected]>
  • Loading branch information
Jarema committed Jul 26, 2024
1 parent dcbd68a commit a2e0251
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions async-nats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1555,9 +1555,11 @@ impl<T: ToServerAddrs + ?Sized> ToServerAddrs for &T {
}

pub(crate) fn is_valid_subject<T: AsRef<str>>(subject: T) -> bool {
!subject.as_ref().contains([' ', '.', '\r', '\n'])
let subject_str = subject.as_ref();
!subject_str.starts_with('.')
&& !subject_str.ends_with('.')
&& subject_str.bytes().all(|c| !c.is_ascii_whitespace())
}

macro_rules! from_with_timeout {
($t:ty, $k:ty, $origin: ty, $origin_kind: ty) => {
impl From<$origin> for $t {
Expand Down

0 comments on commit a2e0251

Please sign in to comment.