Skip to content

Commit c67bfff

Browse files
committed
Ruby: strip \\?\ from display paths
1 parent 4bfcc31 commit c67bfff

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ruby/extractor/src/extractor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub fn extract(
120120
source: &[u8],
121121
ranges: &[Range],
122122
) -> () {
123-
let path_str = format!("{}", path.display());
123+
let path_str = normalize_path(&path);
124124
let span = tracing::span!(
125125
tracing::Level::TRACE,
126126
"extract",
@@ -155,7 +155,7 @@ pub fn extract(
155155

156156
/// Normalizes the path according the common CodeQL specification. Assumes that
157157
/// `path` has already been canonicalized using `std::fs::canonicalize`.
158-
fn normalize_path(path: &Path) -> String {
158+
pub fn normalize_path(path: &Path) -> String {
159159
if cfg!(windows) {
160160
// The way Rust canonicalizes paths doesn't match the CodeQL spec, so we
161161
// have to do a bit of work removing certain prefixes and replacing

ruby/extractor/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn main() -> std::io::Result<()> {
252252
"character-decoding-error",
253253
"Character decoding error",
254254
)
255-
.file(&path.to_string_lossy())
255+
.file(&extractor::normalize_path(&path))
256256
.message(
257257
"Could not decode the file contents as {}: {}. The contents of the file must match the character encoding specified in the {} {}.",
258258
&[
@@ -272,7 +272,7 @@ fn main() -> std::io::Result<()> {
272272
diagnostics_writer.write(
273273
diagnostics_writer
274274
.new_entry("unknown-character-encoding", "Unknown character encoding")
275-
.file(&path.to_string_lossy())
275+
.file(&extractor::normalize_path(&path))
276276
.message(
277277
"Unknown character encoding {} in {} {}.",
278278
&[

0 commit comments

Comments
 (0)