From b39f281c26f626c17700bca18abaa828c68316ff Mon Sep 17 00:00:00 2001
From: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Date: Wed, 26 Mar 2025 10:24:54 +0530
Subject: [PATCH 1/1] Add TAP test

---
 src/bin/scripts/t/020_createdb.pl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl
index a8293390ed..1878177039 100644
--- a/src/bin/scripts/t/020_createdb.pl
+++ b/src/bin/scripts/t/020_createdb.pl
@@ -241,6 +241,22 @@ $node->command_fails(
 	],
 	'fails for invalid locale provider');
 
+# Test creating a database with a newline (\n) in the name
+my $dbname_newline = "invalid\nDB";
+$node->command_fails_like(
+    [ 'createdb', $dbname_newline ],
+    qr/ERROR:  database name contains a newline or carriage return character/,
+    'fails for database name containing newline'
+);
+
+# Test creating a database with a carriage return (\r) in the name
+my $dbname_cr = "invalid\rDB";
+$node->command_fails_like(
+    [ 'createdb', $dbname_cr ],
+    qr/ERROR:  database name contains a newline or carriage return character/,
+    'fails for database name containing carriage return'
+);
+
 # Check use of templates with shared dependencies copied from the template.
 my ($ret, $stdout, $stderr) = $node->psql(
 	'foobar2',
-- 
2.43.0

