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 25
25
#include " modsecurity/transaction.h"
26
26
#include " actions/transformations/transformation.h"
27
27
28
+ #define NBSP 160 // non breaking space char
28
29
29
30
namespace modsecurity {
30
31
namespace actions {
@@ -37,18 +38,27 @@ RemoveWhitespace::RemoveWhitespace(std::string action)
37
38
38
39
std::string RemoveWhitespace::evaluate (std::string value,
39
40
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
+ }
48
56
}
57
+
49
58
return value;
50
59
}
51
60
52
61
} // namespace transformations
53
62
} // namespace actions
54
63
} // namespace modsecurity
64
+
You can’t perform that action at this time.
0 commit comments