Files
taxbaik/TaxBaik.Admin/Program.cs
T
kjh2064 4c04ecfa32
TaxBaik CI/CD / build-and-deploy (push) Failing after 25s
fix: HTML 인코더 설정 - 한글 유니코드 엔티티 과도 인코딩 제거
## 문제
Razor Pages에서 한글 제목이 HTML 유니코드 엔티티로 과도하게 인코딩됨
- 사업자 (한글 '사업자' 등)
- 렌더링 결과: 엔티티 코드가 그대로 표시됨

## 해결
Program.cs에서 WebEncoderOptions 설정
- TextEncoderSettings: UnicodeRanges.All 적용
- 한글 및 다국어 문자를 유니코드 엔티티로 변환하지 않음
- XSS 보호는 유지 (필요시 @Html.Raw() 사용)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-26 18:47:16 +09:00

76 lines
2.4 KiB
C#

using System.Text.Encodings.Web;
using Microsoft.AspNetCore.Authentication.Cookies;
using MudBlazor.Services;
using TaxBaik.Application;
using TaxBaik.Infrastructure;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(opts => {
opts.LoginPath = "/login";
opts.ExpireTimeSpan = TimeSpan.FromHours(8);
opts.Cookie.SameSite = SameSiteMode.Lax;
});
builder.Services.AddAuthorizationCore();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddMudServices();
builder.Services.AddMemoryCache();
// 한글 포함 다국어 문자를 유니코드 엔티티로 변환하지 않도록 설정
builder.Services.Configure<WebEncoderOptions>(opts => {
opts.TextEncoderSettings = new TextEncoderSettings(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();
}
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
}
app.UsePathBase("/taxbaik/admin");
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();
app.MapRazorComponents<TaxBaik.Admin.Components.App>()
.AddInteractiveServerRenderMode();
app.Run();