Opened 10 years ago

Closed 10 years ago

#8128 closed patch (fixed)

SIP/SIMPLE doesn't treat 'SIP:' case-insensitively

Reported by: darkrain42 Owned by: darkrain42
Milestone: 2.5.5 Component: SIMPLE
Version: 2.5.4 Keywords: SIP
Cc:

Description

'SIP:' is not treated the same as 'sip:' for adding a buddy.

16:12:20 < stangor> darkrain42:  every time i restart pidgin sip-simple just ceeps adding si: to 
                    <name>sip:sip:SIP:019160004@russphone.com</name>
16:12:34 < stangor> I<contact>
16:12:35 < stangor> IIII<buddy account='019160003@russphone.com' proto='prpl-simple'>
16:12:35 < stangor> IIIII<name>sip:sip:SIP:019160004@russphone.com</name>
16:12:35 < stangor> IIIII<alias>019160004@russphone.com</alias>
16:12:35 < stangor> IIIII<setting name='last_seen' type='int'>1231977340</setting>
16:12:35 < stangor> IIII</buddy>
16:12:37 < stangor> IIII<setting name='gtk-mute-sound' type='bool'>0</setting>
16:12:39 < stangor> III</contact>
16:13:03 < darkrain42> It keeps adding 'sip:', you mean? or does it add another 'si:'?
16:13:13 < stangor> yes
16:13:25 < stangor> sip:

Patch coming in a moment...

Attachments (4)

strcasestr.patch (1.5 KB) - added by darkrain42 10 years ago.
fix-simple.patch (1.7 KB) - added by darkrain42 10 years ago.
fix-simple.2.patch (1.6 KB) - added by darkrain42 10 years ago.
simple-revert-bogus.patch (2.3 KB) - added by Marcus Sundberg 10 years ago.
Revert completely bogus replace of strncmp() with strcmp()

Download all attachments as: .zip

Change History (12)

Changed 10 years ago by darkrain42

comment:1 Changed 10 years ago by darkrain42

  • Milestone set to 2.5.5
  • Type changed from defect to patch

The prpl was trying to check if buddy names include 'sip:' and, if not, prepending it, but the check was wrong.

Use purple_strcasestr instead of strstr/strcmp, so this should work with both 'SIP:' and 'sip:'.

Changed 10 years ago by darkrain42

comment:2 Changed 10 years ago by darkrain42

Attached a better patch. stangor pointed out that I need to do the equivalent of $foo =~ /^sip:/, not just a strcasestr.

This patch assumes sip names are ASCII (as opposed to, I guess, UTF8 or region-specific). The old code didn't work and assume the same-ish thing, so this is probably a fair assumption.

comment:3 Changed 10 years ago by datallah

  • Status changed from new to pending

Based on my reading of RFC 3261, it doesn't appear that "SIP:*" is a valid SIP URI.

Changed 10 years ago by darkrain42

comment:4 Changed 10 years ago by darkrain42

  • Status changed from pending to new

Attachment (fix-simple.2.patch) added by ticket reporter.

comment:6 Changed 10 years ago by darkrain42

In that case, I propose the attached patch, which fixes the use of strcmp to strncmp (even if one enters 'sip:...', the current code would turn it into 'sip:sip:...')

Changed 10 years ago by Marcus Sundberg

Revert completely bogus replace of strncmp() with strcmp()

comment:7 Changed 10 years ago by Marcus Sundberg

The SIMPLE plugin worked fine before the commit in "Revision: 8790ac55e1883120f6291456de62e845b73e0481"

The attached patch simple reverts the confused strncmp->strcmp replacing. strncmp() is not used because strings lack NUL termination, but because we only want to compare the beginning of the string! For example the Content-Type header may be "text/html;charset=iso-8859-1" instead of just "text/html".

comment:8 Changed 10 years ago by rekkanoryo

  • Owner changed from seanegan to darkrain42

darkrain42 should commit his patch to im.pidgin.pidgin and mention it in the ChangeLog.

comment:9 Changed 10 years ago by rekkanoryo

  • Resolution set to fixed
  • Status changed from new to closed

I committed a combination of Marcus' and darkrain42's patches in a8298f36047255fb82e4fd453c6537d35b41fa77

Note: See TracTickets for help on using tickets.
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!