Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[13.x] Use standard SQL escaping for column comments in MySqlGrammar#59473

Draft
JoshSalway wants to merge 2 commits into
laravel:13.xfrom
JoshSalway:fix/mysql-comment-escaping
Draft

[13.x] Use standard SQL escaping for column comments in MySqlGrammar#59473
JoshSalway wants to merge 2 commits into
laravel:13.xfrom
JoshSalway:fix/mysql-comment-escaping

Conversation

@JoshSalway
Copy link
Copy Markdown

Summary

Replaces addslashes() with str_replace("'", "''", ...) for column comment escaping in MySqlGrammar::modifyComment().

Changes

The modifyComment() method at line 1404 used addslashes() to escape column comments, while compileTableComment() at line 733 in the same file already correctly uses str_replace("'", "''", ...). This change makes column-level comments consistent with table-level comments, using standard SQL single-quote escaping throughout.

addslashes() escapes with backslashes (\') which is MySQL-specific and can be vulnerable to multi-byte character bypass. SQL-standard escaping ('') is what the rest of the grammar already uses.

Test plan

  • testAddingComment passes in both MySqlSchemaGrammarTest and MariaDbSchemaGrammarTest
  • Consistent with compileTableComment() at line 733 in the same file
  • Consistent with PostgresGrammar comment escaping

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant