You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 53ec051
Browse filesBrowse the repository at this point in the historyBrowse files
fix: check a table's path where it is written into SQL
`create table` takes a table's path as it is, with either driver, and
the tedious driver also writes it into `insert bulk`. A table built
from a name always has a path with each part in brackets, but `path`
is a plain property, so a path changed after the table was built
reached the statement unchecked. The same was true of the table name
that `declare()` writes into the name of a composite primary key
constraint.
The path is now checked as a qualified name where it is written, and
before a connection is taken: each part must be bare, or in brackets
or double quotes. A `]` in the constraint name must be doubled. Each
value is read once, so the value checked is the value written. A path
or name that fails raises EINJECT. The existence check
that `create` runs first looks the table up by the path as a string.
The paths and names that `new sql.Table()` builds are written as
before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
// A length, precision or scale is emitted into the same declaration. `max` is the only
35
39
// word the declaration takes there; everything else the server wants is a number.
@@ -74,6 +78,17 @@ module.exports = {
74
78
}
75
79
returnprocedure
76
80
},
81
+
assertSafeTableName: (name)=>{
82
+
// A table's path is written as it is into `create table` and into tedious's `insert bulk`.
83
+
// A table built from a name always has a path whose parts are in brackets, but `path` is a
84
+
// plain property that can be changed after that, so it is checked where it is written.
85
+
// Read once, and return what was read, for the same reason as the type name.
86
+
consttable=String(name).trim()
87
+
if(!TABLE_NAME.test(table)){
88
+
thrownewMSSQLError(`Invalid table name '${table}'. A table name may only contain identifier characters, unless a part is in brackets or double quotes.`,'EINJECT')
0 commit comments