Error: "Can't find nonce in www-auth" -cause regex defined not correctly
I cant auth to sip server, cause class PhpSip cant parse "nonce"
in code we have line
line if (!preg_match('/^WWW-Authenticate: .* nonce="(.*)"/imU',$this->rx_msg, $m))
But I got this string in rx_msg
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.56.1:52619;rport=52619;received=192.168.56.1;branch=z9hG4bK400475
Call-ID: [email protected]
From: <sip:[email protected]>;tag=29476
To: <sip:[email protected]>;tag=z9hG4bK400475
CSeq: 20 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1674462773/ed4af0596a23a091b977b82551037698",opaque="5c230e6a1b3ca71a",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.1.0
Content-Length: 0
So the regexp pattern must be /.*WWW-Authenticate: .* nonce="(.*)"/imU
not /^WWW-Authenticate: .* nonce="(.*)"/imU
I was wrong
I cant figure out, why I got error if regexp is correct.
I checked this on regexOnline
it is correct:

But in php i got error:

the text is same
could somebody explain why this regexp dont work? https://onlinephp.io/c/221e2
Is the spaces in the expression. Remove spaces!
if (!preg_match('/^WWW-Authenticate**:.n**once="(.)"/miU',$x, $m)) {
Às 09:37 de 2023/01/23, Alma Z escreveu:
could somebody explain why this regexp dont work? https://onlinephp.io/c/221e2
— Reply to this email directly, view it on GitHub https://github.com/level7systems/php-sip/issues/12#issuecomment-1400043548, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZETTMNJ67S377DWCAWR4TWTZGMHANCNFSM6AAAAAAUDR4CV4. You are receiving this because you are subscribed to this thread.Message ID: @.***>
OMG. yes.
So, correct pattern should be
/^WWW-Authenticate:.*nonce="(.*)"/imU
not
/^WWW-Authenticate: .* nonce="(.*)"/imU