Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality: Use EncoderReplacementFallback in QuickLook preview provider #16163

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.IO.Pipes;
using System.Security.Principal;
using System.Text;

namespace Files.App.Services.PreviewPopupProviders
{
Expand All @@ -30,13 +31,14 @@ public async Task SwitchPreviewAsync(string path)
private async Task DoPreviewAsync(string path, string message)
{
string pipeName = $"QuickLook.App.Pipe.{WindowsIdentity.GetCurrent().User?.Value}";
var encoding = Encoding.GetEncoding("UTF-8", new EncoderReplacementFallback("?"), new DecoderExceptionFallback());

await using var client = new NamedPipeClientStream(".", pipeName, PipeDirection.Out);
try
{
await client.ConnectAsync(TIMEOUT);

await using var writer = new StreamWriter(client);
await using var writer = new StreamWriter(client, encoding);
await writer.WriteLineAsync($"{message}|{path}");
await writer.FlushAsync();
}
Expand Down