diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index 5801db7c03..0939478349 100644 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -588,8 +588,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