Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log events with a blank "User-Data" header malformed in ESLEvent #67

Open
talmakion opened this issue Apr 3, 2021 · 4 comments
Open
Assignees
Labels

Comments

@talmakion
Copy link

talmakion commented Apr 3, 2021

While ESLEvent works fine with normal events, it is possible to receive log events with no channel UUID, leaving the User-Data header blank. They look like:

Content-Length: 122
Log-Level: 4
Text-Channel: 0
Log-File: sofia_reg.c
Log-Func: sofia_reg_check_gateway
Log-Line: 510
User-Data: 

2021-04-03 19:05:48.882502 [WARNING] sofia_reg.c:510 ast-test-102 Failed Registration [503], setting retry to 30 seconds.

The User-Data line is 'User-Data: \n', including a space. Both the newline and space are stripped, and you end up with this (pretty-printed header dict) where User-Data is considered a continuation of the previous header:

{   'Content-Length': '122',
    'Content-Type': 'log/data',
    'Log-File': 'sofia_reg.c',
    'Log-Func': 'sofia_reg_check_gateway',
    'Log-Level': '4',
    'Log-Line': '510\nUser-Data:',
    'Text-Channel': '0'}

Removing the whitespace strip from ESLEvent.parse_data() doesn't seem to have any adverse affects on other events and fixes this issue:

{   'Content-Length': '122',
    'Content-Type': 'log/data',
    'Log-File': 'sofia_reg.c',
    'Log-Func': 'sofia_reg_check_gateway',
    'Log-Level': '4',
    'Log-Line': '510',
    'Text-Channel': '0',
    'User-Data': ''}
@italorossi
Copy link
Member

*Need testing

@talmakion
Copy link
Author

Is testing something I can assist with, or are you waiting for info from me?

@italorossi
Copy link
Member

Yes, you can write a test case to make sure this event will be correctly parsed. refer to

def test_event_socket_data(self):

@talmakion
Copy link
Author

Does this look better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants