Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.43k stars 382 forks source link

Use a string interpolation and escape single quotes when escaping tables #2677

Closed drunderscore closed 2 years ago

drunderscore commented 2 years ago

This should have previously caused issues, but it didn't, and now it does. Modernize it by using a string interpolation, and properly escaping the single quotes (which you apparently have to do?)

This was noticed when implementing #2675, as the TShock database was regenerated with the new SSC columns, but occasionally failed because of the lack of escapes.

hakusaro commented 2 years ago

@drunderscore can you rebase also you can't just ignore the changelog

drunderscore commented 2 years ago

@hakusaro Rebased and added changelog entry.

Arthri commented 2 years ago

Doesn't this run a query that's structured like this: CREATE TABLE \'TABLENAME\' ...? That's not valid SQLite afaik

drunderscore commented 2 years ago

@Arthri I just checked in sqlite3 -- it is valid. Notice that the query actually being created here would be CREATE TABLE 'bruh', not CREATE TABLE \'bruh\' -- the backslashes are escapes for the single quotes in C#, which are apparently required, as I said in the PR