-
Notifications
You must be signed in to change notification settings - Fork 479
replace spaces from uri #1007
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
replace spaces from uri #1007
Conversation
It is not the task of a core API function to replace anything in the URI it receives from the application. Please fix the URI in your application before it makes call_connect() call and close this pull request. |
You are right. I will keep this pull request open for this matter. |
3021822
to
ecbea57
Compare
Would the changes made to the modules gtk and menu a viable way to address this behavior? I'm still a little unhappy about the code duplicates and unsure about the line-breaks to keep the lines under 79 characters. |
What does your pull request do? Is it just removing spaces from what menu user enters after d or something else? |
I added the configuration setting "whitespace_handing". This setting has three allowed values: none, remove, uri_escape. This setting will change spaces enter in the menu entered after d and in the gtk dial menu. Default behavior is none, which changes nothing. Lets say i want to call the white house. After a quick search i find the number is "+1 202-456-1111". If i copy said number and enter it in the menu or gtk and call unaltered nothing happens. |
mbattista writes:
I added the configuration setting "whitespace_handing". This setting
has three allowed values: none, remove, uri_escape. This setting will
change spaces enter in the menu entered after d and in the gtk dial
menu.
This should be module parameter in gtk and menu modules.
|
Module parameter as in build time instead of runtime? Could you please further elaborate? |
mbattista writes:
Module parameter as in build time instead of runtime?
See config # Module parameters section. So e.g.
menu_whitespace_handling
But since you have also uri_escape alternative, which I assumes escapes
all chars that are not allowed in uri, whitespace does not sound like a
good term.
Also, I don't quite understand the need for this. Why would the user
write +1 202-456-1111 instead of +12024561111? Also, if - chars are
left in the userpart, it is unlikely that a sip proxy or pstn gw would
correctly route the request.
|
It already is in the Module parameters section. I could probably add two parameters instead of just one (menu_whitespace_handling and gtk_whitespace_handling) to differentiate between the modules.
I only escape whitespace character to date. A full blown uri-escape would be way more complex or would add an additional external library. Both of which seems unnecessary as far as i can see it.
Because people want to copy and paste numbers. Most phone numbers are written with spaces to make them more user readable.
At least for my setup removing the white-spaces is sufficient to make the call. |
mbattista writes:
I could probably add two parameters instead of just one
(menu_whitespace_handling and gtk_whitespace_handling) to
differentiate between the modules.
That is what I meant.
I only escape whitespace character to date. A full blown uri-escape
would be way more complex or would add an additional external
library. Both of which seems unnecessary as far as i can see it.
OK.
> Also, I don't quite understand the need for this. Why would the user
write +1 202-456-1111 instead of +12024561111?
Because people want to copy and paste numbers. Most phone numbers are
written with spaces to make them more user readable.
> Also, if - chars are left in the userpart, it is unlikely that a sip
proxy or pstn gw would correctly route the request.
At least for my setup removing the white-spaces is sufficient to make
the call.
Yes, but I bet that in many other SIP Proxy/PSTN Gateway setups - chars
would not be accepted. Can you point to some ITU or other standard
that tells that - chars are OK in E.164 numbers?
|
You are right with this. But since in the menu and the gtk modules it is
|
It's not only about readability here, but also about international standards compliance, because:
However, "+49 (0) 30 12345-67" is simply a wrong German and Austrian writing, unfortunately very common but still violating all standards, even German DIN 5008. In order to support copy & paste from those zillions of websites (or e-mail footers), I highly appreciate your cleanup option (because after your cleanup this leads to a proper "+49301234567" from what I understand). As per RFC 5733 (based on E.164), there is however also "+49.301234567", which doesn't seem to be covered so far. It would be outstanding, if you could extend your PR here slightly.
Shouldn't that be Philosophical: I'm not sure whether |
I extended the PR to also remove dots from the clean number
Since i loop over the pointer I want to start at the beginning of the string, since the user could have simply entered '+' which then could lead to unexpected behavior. I could check the strlen of the given number but then i would have to include
I altered the PR that the (0) now has to be followed by another character in order to remove it and i only remove the first occurrence of (0). So |
In my opinion this is getting far too complicated. There exists tons of different dialing plans in different countries. Better to stick to the original idea and just remove white space from whatever user enters after d or in the corresponding gtk thing in order to make it compliant with sip uri userpart syntax. |
I agree that there are various dialplans worldwide, however the "+49 (0) 30 12345-67" is unfortunately a very common wrong way in Germany and Austria to write a phone number; it even has nothing to do with the dialplan. People would like to express with "+49 (0)" that you shall dial either "+49" or "0". So I still would really like a simple way to strip the wrong "(0)" if it appears after the country code. |
Robert Scheck writes:
I agree that there are various dialplans worldwide, however the "+49
(0) 30 12345-67" is unfortunately a very common wrong way in Germany
and Austria to write a phone number; it even has nothing to do with
the dialplan. People would like to express with "+49 (0)" that you
shall dial either "+49" or "0". So I still would really like a
*simple* way to strip the wrong "(0)" if it appears after the country
code.
Menu and gtk modules are application modules. You could write German
version of them for your users. Another option could be to introduce a
a configuration variable that has regex value and that regex is then
applied to the string that user enters after d.
|
Firstly I found a bug in my gtk module changes that I have to fix asap. gtk saves the cursor juha-h writes:
But you made good and valid points, that just removing whitespaces will not make juha-h writes:
I would rather not, since then future updates to the Menu modules also have to migrated juha-h writes:
While i kind of like the idea of giving the user more freedom, this would be way more |
mbattista writes:
juha-h writes:
> Another option could be to introduce a a configuration variable that has regex value and that regex is then applied to the string that user enters after d.
While i kind of like the idea of giving the user more freedom, this would be way more
complicated to implement and has way more ways to fail than this solution.
re lib has regex functions that could be used. i don't get why there
would be more ways to fail.
|
juha-h writes:
I have used re_regex in the PR.
Lets say our phone number is
Another possibility would be to give the user regex expression of strings he wants It would also be possible to take the list and use the negation before calling re_regex. This added complexity and the component, that the user has no idea, which regex he |
I fixed the gtk bug. I wanted to remove the logic which determines the "(0)" too, but after some research Some examples: |
mbattista writes:
Other problems are:
- removing (0) is not really possible with this solution
- re_regex does not offer a full PCRE which can be confusing for the
user
Then what is the problem with using Linux libpcre?
I my opinion whatever is done, it needs to be a generic solution, not
something that handles a few national formats.
|
I wanted to illustrate with my examples that it is a common mistake and not just a few national formats. So as far as i can see there are three possibilities.
|
can someone else please test this patch, and check that dialing name/numbers @mbattista your patch introduces a lot of unnecessary whitespace/line |
I cleaned up all unnecessary whitespaces. With this line I hope that no changes will be done when names will be dialed. Nonetheless I hope that some else can test this patch. |
it would be nice if someone could test this patch. one week has passed, and no one has stepped up to test it. is there really such a big need for this patch, as you claim? |
Well, for me it was annoying, that I could not copy and paste phone numbers into Since it changes user input, I tried to make the changes as non-intrusive as I This means a baresip user can enable it to use the feature and if he finds a Like i said before, if you feel that this PR would not improve anything or does not |
I will test this patch for sure, but most likely next week; I did not have any spare time last week nor will I have spare any time this week for my hobby projects, sorry. @mbattista, feel free to remind me next week, if I did not provide any test results until next week Tuesday evening. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me the PR works as expected without breaking something (tried regular phone number, tried a phone number where I expect "(0)" to be stripped, tried dialing a contact). I did not see any obvious issue in the C code, however my C knowledge is still not the greatest out there.
(Presumably the changelog [Unreleased] section is for 1.0.0) = Baresip Changelog == [Unreleased] === Added - aac: add AAC_STREAMTYPE_AUDIO enum value - aac: add AAC_ prefix - Video mode param to call_answer(), ua_answer() and ua_hold_answer [#966] - video_stop_display() API function [#977] - module: add path to module_load() function - conf: add conf_configure_buf - test: add usage of g711.so module [#978] - JSON initial codec state command and response [#973] - account_set_video_codecs() API function [#981] - net: add fallback dns nameserver [#996] - gtk: show call_peername in notify title [#1006] - call: Added call_state() API function that returns enum state of the call [#1013] - account_set_stun_user() and account_set_stun_pass() API functions [#1015] - API functions account_stun_uri and account_set_stun_uri. [#1018] - ausine: Audio sine wave input module [#1021] - gtk/menu: replace spaces from uri [#1007] - jack: allowing jack client name to be specified in the config file [#1025] [#1020] - snapshot: Add snapshot_send and snapshot_recv commands [#1029] - webrtc_aec: 'extended_filter' config option [#1030] - avfilter: FFmpeg filter graphs integration [#1038] - reg: view proxy expiry value in reg_status [#1068] - account: add parameter rwait for re-register interval [#1069] - call, stream, menu: add cmd to set the direction of video stream [#1073] === Changed - **Using [baresip/re](https://github.com/baresip/re) fork now** - audio: move calculation to audio_jb_current_value - avformat: clean up docs - gzrtp: update docs - account: increased size of audio codec list to 16 - video: make video_sdp_attr_decode public - config: Derive default audio driver from default audio device [#1009] - jack: modifying info message on jack client creation [#1019] - call: when video stream is disabled, stop also video display [#1023] - dtls_srtp: use tls_set_selfsigned_rsa with keysize 2048 [#1062] [#1056] - rst: use a min ptime of 20ms - aac: change ptime to 4ms === Fixed - avcodec: fix H.264 interop with Firefox - winwave: waveInGetPosition is no longer supported for use as of Windows Vista [#960] - avcodec: call av_hwdevice_ctx_create before if-statement - account: use single quote instead of backtick - ice: fix segfault in connh [#980] - call: Update call->got_offer when re-INVITE or answer to re-INVITE is received [#986] - mk: Test also for /usr/lib64/libspeexdsp.so to cover Fedora/RHEL/CentOS [#992] - config: Allow distribution specific CA trust bundle locations (fixes [#993] - config: Allow distribution specific default audio device (fixes [#994] - mqtt: fix err is never read (found by clang static analyzer) - avcodec: fix err is never read (found by clang static analyzer) - gtk: notification buttons do not work on Systems [#1012] - gtk: fix dtmf_tone and add tones as feedback [#1010] - pulse: drain pulse buffers before freeing [#1016] - jack: jack_play connect all physical ports [#1028] - Makefile: do not try to install modules if build is static [#1031] - gzrtp: media_alloc function is missing [#1034] [#1022] - call: when updating video, check if video stream has been disabled [#1037] - amr: fix length check, fixes [#1011] - modules: fix search path for avdevice.h [#1043] - gtk: declare variables C89 style - config: init newly added member - menu: fix segfault in ua_event_handler [#1059] [#1061] - debug_cmd: fix OpenSSL no-deprecated [#1065] - aac: handle missing bitrate parameter in SDP format - av1: properly configure encoder === Removed - ice: remove support for ICE-lite - ice: remove ice_debug, use log level DEBUG instead - ice: make stun server optional - config: remove ice_debug option (unused) === Contributors (many thanks) - Alfred E. Heggestad - Alexander Gramner - Andrew Webster - Christian Spielberger - Christoph Huber - Davide Alberani - Ethan Funk - Juha Heinanen - mbattista - Michael Malone - Mikl Kurkov - ndilieto - Robert Scheck - Roger Sandholm - Sebastian Reimers [#966]: baresip/baresip#966 [#977]: baresip/baresip#977 [#978]: baresip/baresip#978 [#973]: baresip/baresip#973 [#981]: baresip/baresip#981 [#996]: baresip/baresip#996 [#1006]: baresip/baresip#1006 [#1013]: baresip/baresip#1013 [#1015]: baresip/baresip#1015 [#1018]: baresip/baresip#1018 [#1021]: baresip/baresip#1021 [#1007]: baresip/baresip#1007 [#1025]: baresip/baresip#1025 [#1020]: baresip/baresip#1020 [#1029]: baresip/baresip#1029 [#1030]: baresip/baresip#1030 [#1038]: baresip/baresip#1038 [#1009]: baresip/baresip#1009 [#1019]: baresip/baresip#1019 [#1023]: baresip/baresip#1023 [#1062]: baresip/baresip#1062 [#1056]: baresip/baresip#1056 [#960]: baresip/baresip#960 [#980]: baresip/baresip#980 [#986]: baresip/baresip#986 [#992]: baresip/baresip#992 [#993]: baresip/baresip#993 [#994]: baresip/baresip#994 [#1012]: baresip/baresip#1012 [#1010]: baresip/baresip#1010 [#1016]: baresip/baresip#1016 [#1028]: baresip/baresip#1028 [#1031]: baresip/baresip#1031 [#1034]: baresip/baresip#1034 [#1022]: baresip/baresip#1022 [#1037]: baresip/baresip#1037 [#1011]: baresip/baresip#1011 [#1043]: baresip/baresip#1043 [#1059]: baresip/baresip#1059 [#1061]: baresip/baresip#1061 [#1065]: baresip/baresip#1065 [#1068]: baresip/baresip#1068 [#1069]: baresip/baresip#1069 [#1073]: baresip/baresip#1073 [Unreleased]: baresip/baresip@v0.6.6...HEAD
This pull request would fix rather badly the issue that dialing numbers with spaces will not call the given number.
The correct way to address this issue would probably to uri-escape call-user in general. For this it can either be done by an external library e.g. libcurl (curl_easy_escape) or with some handwritten code which would only detect specific cases.