task 603: range check column move commands

http://code.google.com/p/google-refine/issues/detail?id=603

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2534 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2012-08-18 22:01:23 +00:00
parent 202018fac4
commit 12a61b6ec6
2 changed files with 8 additions and 1 deletions

View File

@ -63,6 +63,10 @@ public class ColumnMoveChange extends ColumnChange {
synchronized (project) { synchronized (project) {
_oldColumnIndex = project.columnModel.getColumnIndexByName(_columnName); _oldColumnIndex = project.columnModel.getColumnIndexByName(_columnName);
if (_oldColumnIndex < 0 || _newColumnIndex < 0
|| _newColumnIndex > project.columnModel.getMaxCellIndex()) {
throw new RuntimeException("Column index out of range");
}
if (_oldColumnGroups == null) { if (_oldColumnGroups == null) {
_oldColumnGroups = new ArrayList<ColumnGroup>(project.columnModel.columnGroups); _oldColumnGroups = new ArrayList<ColumnGroup>(project.columnModel.columnGroups);
} }

View File

@ -1,6 +1,6 @@
/* /*
Copyright 2010, Google Inc. Copyright 2010,2012. Google Inc.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -88,6 +88,9 @@ public class ColumnMoveOperation extends AbstractOperation {
if (project.columnModel.getColumnByName(_columnName) == null) { if (project.columnModel.getColumnByName(_columnName) == null) {
throw new Exception("No column named " + _columnName); throw new Exception("No column named " + _columnName);
} }
if (_index < 0 || _index >= project.columnModel.columns.size()) {
throw new Exception("New column index out of range " + _index);
}
Change change = new ColumnMoveChange(_columnName, _index); Change change = new ColumnMoveChange(_columnName, _index);