From fa0706a8019c336d139924bdf71bdcde3e29bec6 Mon Sep 17 00:00:00 2001 From: MJacred Date: Wed, 24 Jul 2024 18:13:47 +0200 Subject: [PATCH] Fix output filenames that contain a forward slash or backslash --- boilingcore/output.go | 2 ++ boilingcore/output_test.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/boilingcore/output.go b/boilingcore/output.go index 78ba978e0..d91f870a7 100644 --- a/boilingcore/output.go +++ b/boilingcore/output.go @@ -306,6 +306,8 @@ func getLongExt(filename string) string { } func getOutputFilename(tableName string, isTest, isGo bool) string { + tableName = strings.ReplaceAll(strings.ReplaceAll(tableName, `/`, `_`), `\`, `_`) + if strings.HasPrefix(tableName, "_") { tableName = "und" + tableName } diff --git a/boilingcore/output_test.go b/boilingcore/output_test.go index a958b554d..354af46ad 100644 --- a/boilingcore/output_test.go +++ b/boilingcore/output_test.go @@ -122,6 +122,12 @@ func TestGetOutputFilename(t *testing.T) { IsGo: true, Expected: "hello", }, + "contains_forward_slash": { + TableName: "slash/test", + IsTest: false, + IsGo: true, + Expected: "slash_test_model", + }, "begins with underscore": { TableName: "_hello", IsTest: false,