Skip to content

Commit

Permalink
Fix message encoding
Browse files Browse the repository at this point in the history
Fully urlencoded messages do not render properly; so this change removes
teh `urlencoding` dependency and, instead, manually replaces newline
characters with "%0A" to escape newlines.
  • Loading branch information
olix0r committed Feb 13, 2022
1 parent d5ac3a1 commit af7629c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
9 changes: 1 addition & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-action-fmt"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
repository = "https://github.com/olix0r/cargo-action-fmt"
Expand All @@ -12,7 +12,6 @@ Converts cargo check (and clippy) JSON output to the GitHub Action error format
anyhow = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
urlencoding = "2.1"

[dependencies.clap]
version = "3"
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fn main() -> Result<()> {
ClippyObj::BuildScriptExecuted(_) => {}
ClippyObj::CompilerMessage { message } => {
if message.code.is_some() {
let msg = encode_newlines(message.rendered);
for span in message.spans.into_iter() {
println!(
"::{} file={},line={},endLine={},col={},endColumn={}::{}",
Expand All @@ -68,7 +69,7 @@ fn main() -> Result<()> {
span.line_end,
span.column_start,
span.column_end,
urlencoding::encode(&*message.rendered),
msg,
);
}
}
Expand All @@ -83,3 +84,7 @@ fn main() -> Result<()> {

Ok(())
}

fn encode_newlines(orig: String) -> String {
orig.replace('\n', "%0A")
}

0 comments on commit af7629c

Please sign in to comment.