-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: protect from pattern breaking in controller parameters
- Loading branch information
1 parent
1900858
commit 1052516
Showing
4 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
source/webapp/src/main/java/fr/velinfo/webapp/PatternBreakingCharacterRemover.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fr.velinfo.webapp; | ||
|
||
public class PatternBreakingCharacterRemover { | ||
|
||
public static String strip(String string){ | ||
return string.replaceAll("[\n|\r|\t]", "_"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
source/webapp/src/test/java/fr/velinfo/webapp/PatternBreakingCharacterRemoverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package fr.velinfo.webapp; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class PatternBreakingCharacterRemoverTest { | ||
|
||
@Test | ||
void strip_shouldRemoveBreakingCharacters() { | ||
assertEquals("a_b_c_d", PatternBreakingCharacterRemover.strip("a\nb\rc\td")); | ||
} | ||
} |