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

uac_replace_xxx - Remove extra spaces and strip display name on "auto" restore #1742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rrb3942
Copy link
Contributor

@rrb3942 rrb3942 commented Jun 25, 2019

This pull requests makes to changes to the uac_replace_xxx methods.

  1. When stripping the display name it removes everything from the start of the display name up to the start of the uri. This removes trailing spaces and is just a little bit of cleanup on the resulting header.

Previously if you stripped a display name (when was already present) you would end with an extra space in the resulting header. Something like this:
From: sip:[email protected];tag=9fxced76sl**

After the patch:
From: sip:[email protected];tag=9fxced76sl

  1. Currently, changes to the display name are not saved for use with restore_mode "auto". The current behaviour for in-dialog requests in this mode is to replace the URI leaving the display name as-is. This can lead to inconsistent display names and in the worst case information leaking when the display name is changed for privacy reasons (enforcing Privacy: id, etc). This patch makes restore_mode "auto" always strip the display name. I think this is better than inconsistent or leaking display names.

…lay name up to uri. This helps prevent any extra spaces from being present in the resulting header.
@bogdan-iancu bogdan-iancu self-assigned this Jun 28, 2019
@bogdan-iancu
Copy link
Member

@rrb3942 , in regards to the second change (on deleting the display name in auto mode) - the same effect is to be achieved (if really wanted) by doing uac_replace_from("","") on the sequential requests. This gives you the possibility to decide what to do - to remove it or not. With your change, you will not be able to preserve it (if really wanted) on a sequential request.

@rrb3942
Copy link
Contributor Author

rrb3942 commented Jun 28, 2019

@bogdan-iancu Thanks for pointing that out. I hadn't thought of that scenario. I had gone back and forth on the second change, because even though I think it is probably a good default behaviour it can make certain scenarios harder.

I think stripping the display name on sequential is rarely a bad thing to do and consistent.

The current behaviour I would say is inconsistent (when changing the display name) and at worse leaks information (without additional work on the script writers part), which I would consider a bad thing. I would also consider the name leaking on sequential requests 'surprising' to script writers. Right now, for consistent and unsurprising behaviour (stripping or changing) on display name changes users have to resort to additional calls to the replace functions on sequential requests.

What about either a parameter for auto mode, or a new restore mode (auto_strip, or auto_simple?) that causes the name to be stripped on sequential requests? And a doc update to explain the name replacement behaviour.

That way users could pick auto with stripping if they don't want to worry about inconsistency and leaking, and if they have more advance scenarios they can choose auto and handle it in script on sequential requests.

@bogdan-iancu bogdan-iancu self-requested a review July 8, 2019 11:42
@bogdan-iancu
Copy link
Member

@rrb3942 , I see you point on (2) - please make this a separate PR.

For (1) - what is the reason behind the cleanup ? the spaces at the end of the hdr are legal from RFC perspective ;).

@rrb3942
Copy link
Contributor Author

rrb3942 commented Jul 10, 2019

Removed the name stripping on "auto" restore. Will make a new PR for that.

Is 'It looks nicer' a good enough reason on stripping the extra spaces? :)

RFC wise it is allowed, and I haven't run into any systems that have issue with it. Does nag at me every time I see it in a call trace though.

A more 'valid' reason may just be we should be trying to match it as if we built the entire from header from scratch ourselves. And I think in that case we would not be including extra spaces.

@stale
Copy link

stale bot commented Jul 25, 2019

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.

@stale stale bot added the stale label Jul 25, 2019
display_len = body->display.len;
} else {
//Removing, strip all characters up to the URI
display_len = ((body->uri.s-msg->buf) - start_offset) - 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the -1 is for leaving a single space between the URI and the display, right ? If so, I'm not sure that the case of an enclosed URI is properly handled. If I'm not wrong, the < and > are not part of the uri field.
Also, the patch does not cover the situation of multiple spaces before the display, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct that <> are not part of the uri field.

The -1 actually stops us from trimming the < before the uri. I believe a header with a display name, but a non-enclosed uri is against spec (https://www.ietf.org/rfc/rfc2822.txt), so it shouldn't be a problem?

We remove everything from the start of the display name up to, but not including the <. What is left are the spaces from before the display name and the <> enclosed uri.

The patch does not cover multiple spaces before the display, but it could be modified to include those as well.

Example behaviour (verified against a test):

Original:
From: "Name" <sip:user@domain>;tag=as2ed502bc
Stripped:
From: <sip:user@domain>;tag=as2ed502bc

@stale stale bot removed the stale label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 20, 2019

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.

@stale stale bot added the stale label Aug 20, 2019
@stale stale bot removed the stale label Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants