mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 02:46:29 +00:00
minor #2855 Encourage using prepared statements (ntzm)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #2855).
Discussion
----------
Encourage using prepared statements
Although the previous code isn't vulnerable, it could be if copied and used to store user input.
Commits
-------
97d9dc04 Encourage using prepared statements
This commit is contained in:
+2
-2
@@ -409,8 +409,8 @@ First, let's create a temporary in-memory SQLite3 database to work with::
|
||||
{% block content %}Hello {{ name }}{% endblock %}
|
||||
';
|
||||
$now = time();
|
||||
$dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('base.twig', '$base', $now)");
|
||||
$dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('index.twig', '$index', $now)");
|
||||
$dbh->prepare('INSERT INTO templates (name, source, last_modified) VALUES (?, ?, ?)')->execute(['base.twig', $base, $now]);
|
||||
$dbh->prepare('INSERT INTO templates (name, source, last_modified) VALUES (?, ?, ?)')->execute(['index.twig', $index, $now]);
|
||||
|
||||
We have created a simple ``templates`` table that hosts two templates:
|
||||
``base.twig`` and ``index.twig``.
|
||||
|
||||
Reference in New Issue
Block a user