That's a classic textbook bug you learn to test for in software developer class. And as a developer, it's edge cases like this you are always thinking about.
Similar to testing strings containing apostrophes when handling apostrophe delimited strings. Or semicolon delimited name/value pairs containing semicolons.
I wonder if this code was machine generated. There is a bug bounty bonanza right now due to machines creating bugs that are traditionally rare because the human developers had those fail points hammered into them as junior devs.

