mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Ruby: strip \\?\ from display paths
This commit is contained in:
@@ -120,7 +120,7 @@ pub fn extract(
|
||||
source: &[u8],
|
||||
ranges: &[Range],
|
||||
) -> () {
|
||||
let path_str = format!("{}", path.display());
|
||||
let path_str = normalize_path(&path);
|
||||
let span = tracing::span!(
|
||||
tracing::Level::TRACE,
|
||||
"extract",
|
||||
@@ -155,7 +155,7 @@ pub fn extract(
|
||||
|
||||
/// Normalizes the path according the common CodeQL specification. Assumes that
|
||||
/// `path` has already been canonicalized using `std::fs::canonicalize`.
|
||||
fn normalize_path(path: &Path) -> String {
|
||||
pub fn normalize_path(path: &Path) -> String {
|
||||
if cfg!(windows) {
|
||||
// The way Rust canonicalizes paths doesn't match the CodeQL spec, so we
|
||||
// have to do a bit of work removing certain prefixes and replacing
|
||||
|
||||
@@ -252,7 +252,7 @@ fn main() -> std::io::Result<()> {
|
||||
"character-decoding-error",
|
||||
"Character decoding error",
|
||||
)
|
||||
.file(&path.to_string_lossy())
|
||||
.file(&extractor::normalize_path(&path))
|
||||
.message(
|
||||
"Could not decode the file contents as {}: {}. The contents of the file must match the character encoding specified in the {} {}.",
|
||||
&[
|
||||
@@ -272,7 +272,7 @@ fn main() -> std::io::Result<()> {
|
||||
diagnostics_writer.write(
|
||||
diagnostics_writer
|
||||
.new_entry("unknown-character-encoding", "Unknown character encoding")
|
||||
.file(&path.to_string_lossy())
|
||||
.file(&extractor::normalize_path(&path))
|
||||
.message(
|
||||
"Unknown character encoding {} in {} {}.",
|
||||
&[
|
||||
|
||||
Reference in New Issue
Block a user