File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,16 @@ class CSVException : Exception
175
175
assert (ex.toString == " (Row: 1, Col: 2) Unexpected 'b' when converting from type string to type int" );
176
176
}
177
177
178
+ // https://issues.dlang.org/show_bug.cgi?id=24478
179
+ @safe unittest
180
+ {
181
+ import std.exception : collectException;
182
+ import std.algorithm.searching : count;
183
+ string text = " A, B\n 1, 2, 3" ;
184
+ auto ex = collectException! CSVException(csvReader! (string [string ])(text, null ).count);
185
+ assert (ex.toString == " (Row: 1, Col: 3) row contains more values than header" );
186
+ }
187
+
178
188
@safe pure unittest
179
189
{
180
190
import std.string ;
@@ -1179,7 +1189,10 @@ public:
1179
1189
{
1180
1190
for (; ! recordRange.empty; recordRange.popFront())
1181
1191
{
1182
- aa[header[_input.col- 1 ]] = recordRange.front;
1192
+ const i = _input.col - 1 ;
1193
+ if (i >= header.length)
1194
+ throw new CSVException(" row contains more values than header" , _input.row, _input.col);
1195
+ aa[header[i]] = recordRange.front;
1183
1196
}
1184
1197
}
1185
1198
catch (ConvException e)
You can’t perform that action at this time.
0 commit comments