File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed
src/actions/transformations Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 2525#include " modsecurity/transaction.h"
2626#include " actions/transformations/transformation.h"
2727
28+ #define NBSP 160 // non breaking space char
2829
2930namespace modsecurity {
3031namespace actions {
@@ -37,18 +38,27 @@ RemoveWhitespace::RemoveWhitespace(std::string action)
3738
3839std::string RemoveWhitespace::evaluate (std::string value,
3940 Transaction *transaction) {
40- /* *
41- * @todo Implement the transformation RemoveWhitespace
42- */
43- if (transaction) {
44- #ifndef NO_LOGS
45- transaction->debug (4 , " Transformation RemoveWhitespace is " \
46- " not implemented yet." );
47- #endif
41+
42+ long int i = 0 ;
43+
44+ // loop through all the chars
45+ while (i < value.size ()) {
46+ // remove whitespaces and non breaking spaces (NBSP)
47+ if (isspace (value[i])||(value[i] == NBSP)) {
48+ value.erase (i, 1 );
49+ }
50+ else {
51+ /* if the space is not a whitespace char, increment counter
52+ counter should not be incremented if a character is erased because
53+ the index erased will be replaced by the following character */
54+ i++;
55+ }
4856 }
57+
4958 return value;
5059}
5160
5261} // namespace transformations
5362} // namespace actions
5463} // namespace modsecurity
64+
You can’t perform that action at this time.
0 commit comments