Skip to content

Commit

Permalink
Merging all whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Sep 10, 2024
1 parent 3ea0be9 commit cbc52db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static String getUnifiedValue (@Nullable final String sValue, final boole
boolean bLastWasSpace = false;
for (final char c : sValue.toCharArray ())
{
if (c == '\r' || c == '\n' || c == '\t')
if (Character.isWhitespace (c))
{
if (!bLastWasSpace)
aOneLiner[nLineLength++] = ' ';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ public void testGetUnifiedValues ()
assertEquals ("line1 line2", HttpHeaderMap.getUnifiedValue ("line1\r\n\r\r\n\n\n\t\t\tline2", false));
assertEquals ("\"line1 line2\"", HttpHeaderMap.getUnifiedValue ("line1\r\n\r\r\n\n\n\t\t\tline2", true));

assertEquals ("line1 line2", HttpHeaderMap.getUnifiedValue ("line1\r\n\r\r \n\n\n \t\t \tline2", false));
assertEquals ("\"line1 line2\"", HttpHeaderMap.getUnifiedValue ("line1\r\n \r\r\n\n \n\t \t\tline2", true));

// Already quoted
assertEquals ("\"ab cd\"", HttpHeaderMap.getUnifiedValue ("\"ab cd\"", true));
}
Expand Down

0 comments on commit cbc52db

Please sign in to comment.