@@ -129,34 +129,36 @@ const Cell* PropertySheet::getValueFromAlias(const std::string& alias) const
129
129
130
130
bool PropertySheet::isValidCellAddressName (const std::string& candidate)
131
131
{
132
- static const boost::regex gen (" ^[A-Za-z][_A-Za-z0-9]*$" );
133
- boost::cmatch cm;
134
-
135
132
/* Check if it matches a cell reference */
136
- if ( boost::regex_match (candidate. c_str (), cm, gen)) {
137
- static const boost::regex e ( " \\ ${0,1}([A-Z]{1,2}) \\ ${0,1}([0-9]{1,5}) " ) ;
133
+ static const boost::regex e ( " \\ ${0,1}([A-Z]{1,2}) \\ ${0,1}([0-9]{1,5}) " );
134
+ boost::cmatch cm ;
138
135
139
- if (boost::regex_match (candidate.c_str (), cm, e)) {
140
- const boost::sub_match<const char *> colstr = cm[1 ];
141
- const boost::sub_match<const char *> rowstr = cm[2 ];
136
+ if (boost::regex_match (candidate.c_str (), cm, e)) {
137
+ const boost::sub_match<const char *> colstr = cm[1 ];
138
+ const boost::sub_match<const char *> rowstr = cm[2 ];
142
139
143
- if (App::validRow (rowstr.str ()) >= 0 && App::validColumn (colstr.str ())) {
144
- return true ;
145
- }
140
+ if (App::validRow (rowstr.str ()) >= 0 && App::validColumn (colstr.str ())) {
141
+ return true ;
146
142
}
147
143
}
148
144
return false ;
149
145
}
150
146
151
147
bool PropertySheet::isValidAlias (const std::string& candidate)
152
148
{
149
+ /* Ensure it only contains allowed characters */
150
+ static const boost::regex gen (" ^[A-Za-z][_A-Za-z0-9]*$" );
151
+ boost::cmatch cm;
152
+ if (!boost::regex_match (candidate.c_str (), cm, gen)) {
153
+ return false ;
154
+ }
153
155
154
156
/* Check if it is used before */
155
157
if (getValueFromAlias (candidate)) {
156
158
return false ;
157
159
}
158
160
159
- /* check if it would be a valid cell address name, e.g. "A2" or "C3" */
161
+ /* Check if it would be a valid cell address name, e.g. "A2" or "C3" */
160
162
if (isValidCellAddressName (candidate)) {
161
163
return false ;
162
164
}
0 commit comments