Skip to content

Commit 315c59c

Browse files
authored
Merge pull request #343 from softwaremill/refactor-invalid-characters-check
Extracts method that checks whether a character is allowed
2 parents 50dae5d + abbb10c commit 315c59c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

rest/rest-sqs/src/main/scala/org/elasticmq/rest/sqs/SQSRestServerBuilder.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,18 @@ trait SQSLimitsModule {
485485
if (offset < bodyLength) {
486486
val c = body.codePointAt(offset)
487487

488-
// Allow chars: #x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]
489-
if (c == 0x9 || c == 0xA || c == 0xD || (c >= 0x20 && c <= 0xD7FF) || (c >= 0xE000 && c <= 0xFFFD) || (c >= 0x10000 && c <= 0x10FFFF)) {
490-
// Current char is valid
488+
if (isAllowedCharacter(c))
491489
findInvalidCharacter(offset + Character.charCount(c))
492-
} else {
493-
true
494-
}
490+
else true
495491
} else {
496492
false
497493
}
498494
}
499495

496+
// Allow chars: #x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]
497+
def isAllowedCharacter(c: Int): Boolean =
498+
c == 0x9 || c == 0xA || c == 0xD || (c >= 0x20 && c <= 0xD7FF) || (c >= 0xE000 && c <= 0xFFFD) || (c >= 0x10000 && c <= 0x10FFFF)
499+
500500
findInvalidCharacter(0)
501501
}
502502
}

0 commit comments

Comments
 (0)