Skip to content

Commit

Permalink
fix: escape input strings for token alias (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm authored Aug 9, 2024
1 parent 7b08841 commit 3ca83b5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/rs-macro/src/macro_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,20 @@ pub(crate) struct TypeAlias {

impl Parse for TypeAlias {
fn parse(input: ParseStream) -> Result<Self> {
let abi = input
.parse::<Type>()?
.into_token_stream()
.to_string()
.replace(' ', "");
let abi = sanitize_str(&input.parse::<Type>()?.into_token_stream().to_string());

input.parse::<Token![as]>()?;

let alias = input.parse::<Ident>()?.to_string();
let alias = sanitize_str(&input.parse::<Ident>()?.to_string());

Ok(TypeAlias { abi, alias })
}
}

fn sanitize_str(abi: &str) -> String {
abi.trim().replace([' ', '\n', '\t'], "").to_string()
}

fn open_json_file(file_path: &str) -> Result<File> {
File::open(file_path).map_err(|e| {
syn::Error::new(
Expand Down

0 comments on commit 3ca83b5

Please sign in to comment.