fix: correct SQL string escaping for MySQL, InterBase, Firebird and Access#8
Open
vipitec-neo wants to merge 1 commit intohickelsoft:mainfrom
Open
fix: correct SQL string escaping for MySQL, InterBase, Firebird and Access#8vipitec-neo wants to merge 1 commit intohickelsoft:mainfrom
vipitec-neo wants to merge 1 commit intohickelsoft:mainfrom
Conversation
47aa520 to
259d071
Compare
…ccess
SQL_Escape_String had two bugs:
1. MySQL: backslash and quote escaping were in the wrong order.
Input O'Brien -> O\'Brien -> O\\'Brien (double-escaped).
Fix: escape backslashes first, then quotes.
2. InterBase, Firebird, Access: these DBMS use SQL-standard
double-quote escaping (''), not backslash escaping (\').
Using backslash escaping produced invalid SQL on these engines.
SQL Server escaping (double-quote style) was already correct.
259d071 to
daeb519
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SQL_Escape_StringinC_Database.pashad two bugs:1. MySQL: Wrong escaping order
Backslash and quote escaping were in the wrong order, causing double-escaping:
O'Brien'→\':O\'Brien\→\\:O\\'Brien← broken!2. InterBase, Firebird, Access: Wrong escaping method
These DBMS use SQL-standard
''escaping, not MySQL-style\'. The old code produced invalid SQL.Fix
\first, then'(correct order)''(SQL standard) instead of\'Tests
Unit Tests (Free Pascal)
9 tests verifying the escaping functions in isolation. Compiled with
fpc.Integration Tests (Docker)
7 tests against real database engines:
''works ✅,\'rejected ✅, backslash literal works ✅\'works ✅,\\needed for backslash ✅, unescaped\swallowed ✅, double-escaping bug confirmed ✅Not tested (no Docker images available)
''escaping is identical.''escaping per Microsoft docs.CI
GitHub Actions workflow included — runs both unit and integration tests automatically.