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
175175 assert (ex.toString == " (Row: 1, Col: 2) Unexpected 'b' when converting from type string to type int" );
176176}
177177
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+
178188@safe pure unittest
179189{
180190 import std.string ;
@@ -1179,7 +1189,10 @@ public:
11791189 {
11801190 for (; ! recordRange.empty; recordRange.popFront())
11811191 {
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;
11831196 }
11841197 }
11851198 catch (ConvException e)
You can’t perform that action at this time.
0 commit comments