diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index 2bfd224ebb..98ba01006d 100644 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -505,8 +505,11 @@ sub read_request { $raw_length = length $buffer; $buffer =~ s/^\s*[^A-z0-9]+//s; - # Every line must start with a "real" character. Not whitespace, control chars, etc. - $buffer =~ s/[^A-z0-9]+$//s; + # Remove leading/trailing control characters and whitespace. + # SIP2 messages should be a single printable line; this defensively + # cleans up stray CR/LF or junk from buggy or long-lived client connections. + $buffer =~ s/^[[:cntrl:]\s]+//; + $buffer =~ s/[[:cntrl:]\s]+$//; # Same for the end. Note this catches the problem some clients have sending empty fields at the end, like ||| $buffer =~ s/\015?\012//g; # Extra line breaks must die