[OpenSIPS-Users] Gracefully handling bad from header

Bogdan-Andrei Iancu bogdan at opensips.org
Fri Apr 16 07:50:44 EST 2021


Hi Calvin,

I'm afraid there is not much you can do, especially if (via script and 
modules) you will need access to the "fixed" FROM  - the msg changes you 
do via script are not applied on the spot, but only when the msg is sent 
out -> so you do not see your own changes.

But if you do not need to access the FROM hdr, you can do a brutal 
replacement with remove_hf() and append_hf(), but not sure if you will 
be able to extract any other parts of the FROM (if you want o preserve 
them).

Regards,

Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
   https://www.opensips-solutions.com
OpenSIPS Bootcamp 2021 online
   https://opensips.org/training/OpenSIPS_eBootcamp_2021/

On 4/15/21 8:47 PM, Calvin Ellison wrote:
> I would like to more gracefully handle non-RFC compliant From headers. 
> Is it possible to fix them with regex or a string replacement so I can 
> process them?
>
> Most often the misbehavior is a space in the user part:
>
> <sip:redacter Coredact@
> <sip:redact0330 @
>
> Other times there's an unclosed double quote on the friendly-name part 
> or some kind of non-printing character in the friendly-name or user 
> part. It's garbage that will ultimately be rejected, but the failure 
> to parse is preventing me from logging the offending trunk ID in the 
> 'otg=' parameter of the From header.
>
> opensips 3.1.1 (x86_64/linux) with commit to remove unnecessary regex 
> limitation
> https://github.com/OpenSIPS/opensips/commit/a8f8aabc245ca86bd40a9eddf9befcd74a087be1
>
> Here's the error followed by xlog $mb
>
> Apr 15 15:26:24  /usr/sbin/opensips[13864]: 
> ERROR:core:parse_from_header: bad from header
> Apr 15 15:26:24  /usr/sbin/opensips[13864]: 
> ERROR:core:pv_get_from_attr: cannot parse From header
> Apr 15 15:26:24  /usr/sbin/opensips[13864]: INVITE 
> sip:redact at redact:5060 SIP/2.0#015#012Via: SIP/2.0/UDP 
> redact:5060;branch=z9hG4bK1sansay2313795380rdb15209#015#012Record-Route: 
> <sip:sansay2313795380rdb15209 at redact:5060;lr;transport=udp>#015#012To: 
> <sip:redact at redact>#015#012From: <sip:redact0330 
> @redact;otg=redact;qtype=ers>;tag=sansay2313795380rdb15209#015#012Call-ID: 
> ers-1718949283-0-660497714 at redact#015#012CSeq: 1 
> INVITE#015#012Contact: <sip:redact0330 
> @redact:5060>#015#012P-Asserted-Identity: 
> <sip:redact0330%20 at redact;user=phone>#015#012Remote-Party-ID: 
> <sip:redact0330%20 at redact>;privacy=off;screen=yes#015#012Max-Forwards: 
> 63#015#012Content-Length: 0#015#012#015#012
>
>
> Regards,
>
> *Calvin Ellison*
> Systems Architect
> calvin.ellison at voxox.com <mailto:calvin.ellison at voxox.com>
> +1 (213) 285-0555
>
> -----------------------------------------------
> *voxox.com <http://www.voxox.com/> *
> 5825 Oberlin Drive, Suite 5
> San Diego, CA 92121
>
> Voxox
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20210416/2a3dc0e6/attachment-0001.html>


More information about the Users mailing list