Skip to content

Commit

Permalink
PythonLayer allows to import nested modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tnarihi committed Mar 31, 2015
1 parent eedcd7b commit fd8bcf6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/caffe/layer_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ template <typename Dtype>
shared_ptr<Layer<Dtype> > GetPythonLayer(const LayerParameter& param) {
string module_name = param.python_param().module();
string layer_name = param.python_param().layer();
// Check injection. This doesn't allow nested importing.
boost::regex expression("[a-zA-Z_][a-zA-Z0-9_]*");
// Check injection. This allows nested import.
boost::regex expression("[a-zA-Z_][a-zA-Z0-9_]*"
"(\\.[a-zA-Z_][a-zA-Z0-9_]*)*");
CHECK(boost::regex_match(module_name, expression))
<< "Module name is invalid: " << module_name;
CHECK(boost::regex_match(layer_name, expression))
Expand Down

0 comments on commit fd8bcf6

Please sign in to comment.