Re: [OpenSIPS-Users] Gracefully handling bad from header

2021-04-16 Thread Bogdan-Andrei Iancu

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:

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@redact:5060 SIP/2.0#015#012Via: SIP/2.0/UDP 
redact:5060;branch=z9hG4bK1sansay2313795380rdb15209#015#012Record-Route: 
#015#012To: 
#015#012From: @redact;otg=redact;qtype=ers>;tag=sansay2313795380rdb15209#015#012Call-ID: 
ers-1718949283-0-660497714@redact#015#012CSeq: 1 
INVITE#015#012Contact: @redact:5060>#015#012P-Asserted-Identity: 
#015#012Remote-Party-ID: 
;privacy=off;screen=yes#015#012Max-Forwards: 
63#015#012Content-Length: 0#015#012#015#012



Regards,

*Calvin Ellison*
Systems Architect
calvin.elli...@voxox.com 
+1 (213) 285-0555

---
*voxox.com  *
5825 Oberlin Drive, Suite 5
San Diego, CA 92121

Voxox

___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


[OpenSIPS-Users] Gracefully handling bad from header

2021-04-15 Thread Calvin Ellison
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:

#015#012To:
#015#012From: ;tag=sansay2313795380rdb15209#015#012Call-ID:
ers-1718949283-0-660497714@redact#015#012CSeq: 1 INVITE#015#012Contact:
#015#012P-Asserted-Identity:
#015#012Remote-Party-ID:
;privacy=off;screen=yes#015#012Max-Forwards:
63#015#012Content-Length: 0#015#012#015#012


Regards,

*Calvin Ellison*
Systems Architect
calvin.elli...@voxox.com
+1 (213) 285-0555

---
*voxox.com  *
5825 Oberlin Drive, Suite 5
San Diego, CA 92121
[image: Voxox]
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users