876ec7345b
TaxBaik CI/CD / build-and-deploy (push) Successful in 1m1s
## 근본 원인 Razor Pages 기본 HtmlEncoder가 한글을 유니코드 엔티티로 과도 인코딩 - 데이터: '사업자' → 렌더링: '사업자' - 사용자에게 보이는 것: 인코딩된 엔티티 텍스트 ## 해결 Program.cs에서 HtmlEncoder를 UnicodeRanges.All로 초기화 - ASP.NET Core DI에 HtmlEncoder.Create(UnicodeRanges.All) 등록 - 모든 유니코드 문자를 UTF-8 문자 그대로 렌더링 - XSS 보호는 유지 (HTML 마크업 문자는 여전히 이스케이핑) ## 결과 ✅ 한글 제목 정상 표시 ✅ 블로그 카테고리 정상 표시 ✅ 다국어 지원 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using System.IO.Compression;
|
|
using System.Text.Encodings.Web;
|
|
using System.Text.Unicode;
|
|
using Microsoft.AspNetCore.ResponseCompression;
|
|
using TaxBaik.Application;
|
|
using TaxBaik.Infrastructure;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddRazorPages();
|
|
builder.Services.AddMemoryCache();
|
|
builder.Services.AddResponseCompression(opts => {
|
|
opts.Providers.Add<GzipCompressionProvider>();
|
|
});
|
|
|
|
// 한글 포함 다국어 문자를 유니코드 엔티티로 변환하지 않도록 설정
|
|
builder.Services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
|
|
|
|
builder.Services.AddInfrastructure();
|
|
builder.Services.AddApplication();
|
|
|
|
// Register version info
|
|
var versionInfo = new VersionInfo();
|
|
var versionFilePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "version.txt");
|
|
if (File.Exists(versionFilePath))
|
|
{
|
|
var lines = File.ReadAllLines(versionFilePath);
|
|
foreach (var line in lines)
|
|
{
|
|
if (line.StartsWith("Version:"))
|
|
versionInfo.Version = line.Substring("Version:".Length).Trim();
|
|
else if (line.StartsWith("Built:"))
|
|
versionInfo.Built = line.Substring("Built:".Length).Trim();
|
|
}
|
|
}
|
|
builder.Services.AddSingleton(versionInfo);
|
|
|
|
var app = builder.Build();
|
|
|
|
// Run migrations on startup
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var connectionFactory = scope.ServiceProvider.GetRequiredService<TaxBaik.Domain.Interfaces.IDbConnectionFactory>();
|
|
var cs = builder.Configuration.GetConnectionString("Default")
|
|
?? throw new InvalidOperationException("Missing connection string");
|
|
var migrationRunner = new TaxBaik.Infrastructure.Data.MigrationRunner(cs, connectionFactory);
|
|
await migrationRunner.RunAsync();
|
|
}
|
|
|
|
app.UsePathBase("/taxbaik");
|
|
app.UseResponseCompression();
|
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
app.UseAntiforgery();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.MapRazorPages();
|
|
|
|
app.Run();
|