Skip to content

Commit 14133db

Browse files
committed
Add a warning when overwriting POST variable values with $x
See sqlpage#342
1 parent 5ad18b9 commit 14133db

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- reuse the existing opened database connection for the current query in `sqlpage.run_sql` instead of opening a new one. This makes it possible to create a temporary table in a file, and reuse it in an included script, create a SQL transaction that spans over multiple run_sql calls, and should generally make run_sql more performant.
1010
- Fixed a bug in the cookie component where removing a cookie from a subdirectory would not work.
1111
- [Updated SQL parser](https://github.com/sqlparser-rs/sqlparser-rs/blob/main/CHANGELOG.md#0470-2024-06-01). Fixes support for `AT TIME ZONE` in postgres. Fixes `GROUP_CONCAT()` in MySQL.
12+
- Add a new warning message in the logs when trying to use `SET $x = ` when there is already a form field named `x`.
1213

1314
## 0.22.0 (2024-05-29)
1415
- **Important Security Fix:** The behavior of `SET $x` has been modified to match `SELECT $x`.

src/webserver/database/execute_queries.rs

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ fn vars_and_name<'a, 'b>(
163163
match variable {
164164
StmtParam::PostOrGet(name) => {
165165
if request.post_variables.contains_key(name) {
166+
log::warn!("Deprecation warning! Setting the value of ${name}, but there is already a form field named :{name}. This will stop working soon. Please rename the variable, or use :{name} directly if you intended to overwrite the posted form field value.");
166167
Ok((&mut request.post_variables, name))
167168
} else {
168169
Ok((&mut request.get_variables, name))

src/webserver/database/sql.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use crate::{AppState, Database};
66
use anyhow::Context;
77
use async_trait::async_trait;
88
use sqlparser::ast::{
9-
BinaryOperator, CastKind, CharacterLength, DataType, Expr, Function, FunctionArg, FunctionArgExpr, FunctionArgumentList, FunctionArguments, Ident, ObjectName, OneOrManyWithParens, Statement, Value, VisitMut, VisitorMut
9+
BinaryOperator, CastKind, CharacterLength, DataType, Expr, Function, FunctionArg,
10+
FunctionArgExpr, FunctionArgumentList, FunctionArguments, Ident, ObjectName,
11+
OneOrManyWithParens, Statement, Value, VisitMut, VisitorMut,
1012
};
1113
use sqlparser::dialect::{Dialect, MsSqlDialect, MySqlDialect, PostgreSqlDialect, SQLiteDialect};
1214
use sqlparser::parser::{Parser, ParserError};

0 commit comments

Comments
 (0)