comparison OrthancServer/Search/LookupIdentifierQuery.cpp @ 1764:9ead18ef460a

escape
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Oct 2015 16:08:59 +0100
parents 318c2e83c2bd
children b1291df2f780
comparison
equal deleted inserted replaced
1763:f7014cca73c7 1764:9ead18ef460a
169 } 169 }
170 170
171 171
172 std::string LookupIdentifierQuery::NormalizeIdentifier(const std::string& value) 172 std::string LookupIdentifierQuery::NormalizeIdentifier(const std::string& value)
173 { 173 {
174 std::string s = Toolbox::ConvertToAscii(Toolbox::StripSpaces(value)); 174 std::string t;
175 Toolbox::ToUpperCase(s); 175 t.reserve(value.size());
176 return s; 176
177 for (size_t i = 0; i < value.size(); i++)
178 {
179 if (value[i] == '%' ||
180 value[i] == '_')
181 {
182 t.push_back(' '); // These characters might break wildcard queries in SQL
183 }
184 else if (isascii(value[i]) &&
185 !iscntrl(value[i]) &&
186 (!isspace(value[i]) || value[i] == ' '))
187 {
188 t.push_back(value[i]);
189 }
190 }
191
192 Toolbox::ToUpperCase(t);
193
194 return Toolbox::StripSpaces(t);
177 } 195 }
178 196
179 197
180 void LookupIdentifierQuery::StoreIdentifiers(IDatabaseWrapper& database, 198 void LookupIdentifierQuery::StoreIdentifiers(IDatabaseWrapper& database,
181 int64_t resource, 199 int64_t resource,