From b0e2bc415fe9ed04fd928b7c3705a8630352919d Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 16 Jan 2023 12:11:54 +0100 Subject: [PATCH] [platform] setting Windows Defender helper script diagnostic output encoding (IDEA-224689) GitOrigin-RevId: a1d43d955ada2b2d70278337c5f6e8804f14a0a5 --- bin/win/defender-exclusions.ps1 | 2 ++ .../src/com/intellij/diagnostic/WindowsDefenderChecker.java | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/win/defender-exclusions.ps1 b/bin/win/defender-exclusions.ps1 index f77807fe2f23..1fb70c1e3014 100644 --- a/bin/win/defender-exclusions.ps1 +++ b/bin/win/defender-exclusions.ps1 @@ -5,6 +5,8 @@ #Requires -RunAsAdministrator +[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + if ($args.Count -eq 0) { Write-Host "usage: $PSCommandPath path [path ...]" exit 1 diff --git a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java index 93a64da4d925..bfdeb7d4627a 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.diagnostic; import com.intellij.execution.ExecutionException; @@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -180,7 +181,8 @@ public class WindowsDefenderChecker { Stream.of(psh.getPath(), "-ExecutionPolicy", "Bypass", "-NonInteractive", "-File", script.toString()), paths.stream().map(Path::toString) ).toList()), - ""); + "" + ).withCharset(StandardCharsets.UTF_8); output = run(command); if (output.getExitCode() != 0) { LOG.info("script failed:\n[" + output.getExitCode() + "] " + command + "\noutput: " + output.getStdout().trim());