libpurple/util.c

Thu, 24 Apr 2025 21:42:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 24 Apr 2025 21:42:59 -0500
changeset 43241
e41969a43e42
parent 42999
5a506dee26d2
permissions
-rw-r--r--

Add Purple.Contact.is_own_account

This checks to see if a Purple.Contact shares the Purple.ContactInfo with the
account it is tied to.

Testing Done:
Ran the unit tests under valgrind and called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/3985/

42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
1 /*
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
2 * Purple - Internet Messaging Library
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
4 *
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 8026
diff changeset
7 * source distribution.
1
efe077a7e70d [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
12 * any later version.
1
efe077a7e70d [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
17 * more details.
1
efe077a7e70d [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42473
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
1
efe077a7e70d [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 */
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
22
42410
563e7a17c220 Fix possible clash of config headers
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42307
diff changeset
23 #include <purpleconfig.h>
41039
f108e108784e Revert RR 903
Gary Kramlich <grim@reaperworld.com>
parents: 41033
diff changeset
24
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
25 #include <glib/gi18n-lib.h>
42997
368deff13c21 Split purpleprivate.h up into individual files
Gary Kramlich <grim@reaperworld.com>
parents: 42874
diff changeset
26 #include <glib/gstdio.h>
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
27
41682
289867067994 Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents: 41673
diff changeset
28 #include <ctype.h>
289867067994 Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents: 41673
diff changeset
29
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15482
diff changeset
30 #include "core.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5826
diff changeset
31 #include "debug.h"
5545
a8b1a1262402 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5532
diff changeset
32 #include "prefs.h"
41181
e859c41d8996 Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents: 41155
diff changeset
33 #include "purpleaccountmanager.h"
40853
d3518ff99fa7 rename conversation.[ch] to purpleconversation.[ch] and split PurpleConversationUiOps out to its own file to avoid circular include issues.
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
34 #include "purpleconversation.h"
41237
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents: 41236
diff changeset
35 #include "purplepath.h"
41155
922c9e70900c Rename protocol.[ch] to purpleprotocol.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 41039
diff changeset
36 #include "purpleprotocol.h"
7094
8f9588491993 [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7078
diff changeset
37 #include "util.h"
8f9588491993 [gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents: 7078
diff changeset
38
42434
622b4989d073 Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42410
diff changeset
39 #ifdef _WIN32
622b4989d073 Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42410
diff changeset
40 # include "win32/libc_interface.h"
622b4989d073 Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42410
diff changeset
41 #endif
622b4989d073 Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42410
diff changeset
42
33538
cbeb76707f12 Better implementation of purple_escape_js
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33537
diff changeset
43 #include <json-glib/json-glib.h>
cbeb76707f12 Better implementation of purple_escape_js
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33537
diff changeset
44
42280
e29c71fb13e9 Remove internal.h
Gary Kramlich <grim@reaperworld.com>
parents: 42260
diff changeset
45 #define BUF_LEN 2048
e29c71fb13e9 Remove internal.h
Gary Kramlich <grim@reaperworld.com>
parents: 42260
diff changeset
46
21238
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20992
diff changeset
47 void
41237
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents: 41236
diff changeset
48 purple_util_init(void) {
21238
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20992
diff changeset
49 }
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20992
diff changeset
50
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20992
diff changeset
51 void
41237
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents: 41236
diff changeset
52 purple_util_uninit(void) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents: 41236
diff changeset
53 purple_util_set_user_dir(NULL);
21238
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20992
diff changeset
54 }
cd326828c870 Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@pidgin.im>
parents: 20992
diff changeset
55
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
56 /**************************************************************************
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
57 * Path/Filename Functions
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
58 **************************************************************************/
38870
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
59 static gboolean
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
60 purple_util_write_data_to_file_common(const char *dir, const char *filename, const char *data, gssize size)
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
61 {
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
62 gchar *filename_full;
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
63 gboolean ret = FALSE;
38872
af422a3fb924 Add purple_util_write_data_to_*_file declarations
qarkai <qarkai@gmail.com>
parents: 38871
diff changeset
64
38870
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
65 g_return_val_if_fail(dir != NULL, FALSE);
38872
af422a3fb924 Add purple_util_write_data_to_*_file declarations
qarkai <qarkai@gmail.com>
parents: 38871
diff changeset
66
38870
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
67 purple_debug_misc("util", "Writing file %s to directory %s",
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
68 filename, dir);
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
69
38874
0fc4ba7fa2be Make XDG dir structure inside custom user dir
qarkai <qarkai@gmail.com>
parents: 38872
diff changeset
70 /* Ensure the directory exists */
38870
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
71 if (!g_file_test(dir, G_FILE_TEST_IS_DIR))
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
72 {
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
73 if (g_mkdir(dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
74 {
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
75 purple_debug_error("util", "Error creating directory %s: %s\n",
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
76 dir, g_strerror(errno));
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
77 return FALSE;
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
78 }
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
79 }
38872
af422a3fb924 Add purple_util_write_data_to_*_file declarations
qarkai <qarkai@gmail.com>
parents: 38871
diff changeset
80
38899
73b49f76016a Some fixes
qarkai <qarkai@gmail.com>
parents: 38893
diff changeset
81 filename_full = g_build_filename(dir, filename, NULL);
40656
0d388fcfd3bf Remove one more purple_util_write_data_to_file_absolute.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40637
diff changeset
82 ret = g_file_set_contents(filename_full, data, size, NULL);
0d388fcfd3bf Remove one more purple_util_write_data_to_file_absolute.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40637
diff changeset
83 g_free(filename_full);
38872
af422a3fb924 Add purple_util_write_data_to_*_file declarations
qarkai <qarkai@gmail.com>
parents: 38871
diff changeset
84
38870
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
85 return ret;
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
86 }
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
87
10414
6b10b76933e1 [gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents: 10372
diff changeset
88 gboolean
38870
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
89 purple_util_write_data_to_config_file(const char *filename, const char *data, gssize size)
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
90 {
38881
25cb836b9cec Use proper directories for writing data.
Arkadiy Illarionov <qarkai@gmail.com>
parents: 38874
diff changeset
91 const char *config_dir = purple_config_dir();
38870
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
92 gboolean ret = purple_util_write_data_to_file_common(config_dir, filename, data, size);
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
93
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
94 return ret;
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
95 }
575e41bfc15e Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents: 38051
diff changeset
96
38877
4e9c691a1d2d Add functions for reading XML files from XDG dirs
qarkai <qarkai@gmail.com>
parents: 38876
diff changeset
97 PurpleXmlNode *
4e9c691a1d2d Add functions for reading XML files from XDG dirs
qarkai <qarkai@gmail.com>
parents: 38876
diff changeset
98 purple_util_read_xml_from_config_file(const char *filename, const char *description)
4e9c691a1d2d Add functions for reading XML files from XDG dirs
qarkai <qarkai@gmail.com>
parents: 38876
diff changeset
99 {
4e9c691a1d2d Add functions for reading XML files from XDG dirs
qarkai <qarkai@gmail.com>
parents: 38876
diff changeset
100 return purple_xmlnode_from_file(purple_config_dir(), filename, description, "util");
4e9c691a1d2d Add functions for reading XML files from XDG dirs
qarkai <qarkai@gmail.com>
parents: 38876
diff changeset
101 }
4e9c691a1d2d Add functions for reading XML files from XDG dirs
qarkai <qarkai@gmail.com>
parents: 38876
diff changeset
102
11878
4c2661df91bb [gaim-migrate @ 14169]
Sean Egan <seanegan@pidgin.im>
parents: 11780
diff changeset
103 gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
104 purple_running_gnome(void)
11878
4c2661df91bb [gaim-migrate @ 14169]
Sean Egan <seanegan@pidgin.im>
parents: 11780
diff changeset
105 {
13616
7cf0f845d2d6 [gaim-migrate @ 16001]
Daniel Atallah <datallah@pidgin.im>
parents: 13614
diff changeset
106 #ifndef _WIN32
38043
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
107 gchar *tmp = g_find_program_in_path("gvfs-open");
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
108
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
109 if (tmp == NULL) {
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
110 tmp = g_find_program_in_path("gnome-open");
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
111
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
112 if (tmp == NULL) {
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
113 return FALSE;
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
114 }
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
115 }
3549ff786eab util: Fix purple_running_gnome() to check for gvfs-open too
Mike Ruprecht <cmaiku@gmail.com>
parents: 37160
diff changeset
116
12483
38fc67810cdb [gaim-migrate @ 14795]
Richard Laager <rlaager@pidgin.im>
parents: 12110
diff changeset
117 g_free(tmp);
38fc67810cdb [gaim-migrate @ 14795]
Richard Laager <rlaager@pidgin.im>
parents: 12110
diff changeset
118
21665
a1a724a89a03 Allow empty GNOME_DESKTOP_SESSION_ID to "fail" the running_gnome check as
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21468
diff changeset
119 tmp = (gchar *)g_getenv("GNOME_DESKTOP_SESSION_ID");
a1a724a89a03 Allow empty GNOME_DESKTOP_SESSION_ID to "fail" the running_gnome check as
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21468
diff changeset
120
a1a724a89a03 Allow empty GNOME_DESKTOP_SESSION_ID to "fail" the running_gnome check as
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21468
diff changeset
121 return ((tmp != NULL) && (*tmp != '\0'));
13616
7cf0f845d2d6 [gaim-migrate @ 16001]
Daniel Atallah <datallah@pidgin.im>
parents: 13614
diff changeset
122 #else
7cf0f845d2d6 [gaim-migrate @ 16001]
Daniel Atallah <datallah@pidgin.im>
parents: 13614
diff changeset
123 return FALSE;
7cf0f845d2d6 [gaim-migrate @ 16001]
Daniel Atallah <datallah@pidgin.im>
parents: 13614
diff changeset
124 #endif
12483
38fc67810cdb [gaim-migrate @ 14795]
Richard Laager <rlaager@pidgin.im>
parents: 12110
diff changeset
125 }
38fc67810cdb [gaim-migrate @ 14795]
Richard Laager <rlaager@pidgin.im>
parents: 12110
diff changeset
126
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
127 /**************************************************************************
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
128 * String Functions
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
129 **************************************************************************/
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
130 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
131 purple_str_strip_char(char *text, char thechar)
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
132 {
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
133 int i, j;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
134
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
135 g_return_if_fail(text != NULL);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
136
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
137 for (i = 0, j = 0; text[i]; i++)
11920
be80617ec59b [gaim-migrate @ 14211]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11878
diff changeset
138 if (text[i] != thechar)
11142
3ed4fc774b87 [gaim-migrate @ 13206]
Mark Doliner <markdoliner@pidgin.im>
parents: 11137
diff changeset
139 text[j++] = text[i];
3ed4fc774b87 [gaim-migrate @ 13206]
Mark Doliner <markdoliner@pidgin.im>
parents: 11137
diff changeset
140
30702
8a1938367841 These are dead increments.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30515
diff changeset
141 text[j] = '\0';
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
142 }
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
143
8341
dc43b1acfc1a [gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents: 8163
diff changeset
144 gchar *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
145 purple_strreplace(const char *string, const char *delimiter,
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
146 const char *replacement)
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
147 {
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
148 gchar **split;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
149 gchar *ret;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
150
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
151 g_return_val_if_fail(string != NULL, NULL);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
152 g_return_val_if_fail(delimiter != NULL, NULL);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
153 g_return_val_if_fail(replacement != NULL, NULL);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
154
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
155 split = g_strsplit(string, delimiter, 0);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
156 ret = g_strjoinv(replacement, split);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
157 g_strfreev(split);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
158
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
159 return ret;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
160 }
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
161
34145
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
162 void
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
163 purple_str_wipe(gchar *str)
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
164 {
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
165 if (str == NULL)
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
166 return;
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
167 memset(str, 0, strlen(str));
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
168 g_free(str);
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
169 }
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33824
diff changeset
170
42060
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
171 gboolean
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
172 purple_strmatches(const char *pattern, const char *str) {
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
173 char *normal_pattern = NULL;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
174 char *normal_str = NULL;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
175 char *cmp_pattern = NULL;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
176 char *cmp_str = NULL;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
177 char *idx_pattern = NULL;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
178 char *idx_str = NULL;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
179
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
180 g_return_val_if_fail(pattern != NULL, FALSE);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
181
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
182 /* Short circuit on NULL and empty string. */
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
183 if(purple_strempty(str)) {
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
184 return FALSE;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
185 }
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
186
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
187 normal_pattern = g_utf8_normalize(pattern, -1, G_NORMALIZE_ALL);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
188 cmp_pattern = g_utf8_casefold(normal_pattern, -1);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
189 g_free(normal_pattern);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
190
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
191 normal_str = g_utf8_normalize(str, -1, G_NORMALIZE_ALL);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
192 cmp_str = g_utf8_casefold(normal_str, -1);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
193 g_free(normal_str);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
194
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
195 idx_pattern = cmp_pattern;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
196 idx_str = cmp_str;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
197
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
198 /* I know while(TRUE)'s suck, but the alternative would be a multi-line for
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
199 * loop that wouldn't have the additional comments, which is much better
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
200 * IMHO. -- GK 2023-01-24.
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
201 */
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
202 while(TRUE) {
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
203 gunichar character = g_utf8_get_char(idx_pattern);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
204
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
205 /* If we've reached the end of the pattern, we're done. */
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
206 if(character == 0) {
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
207 break;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
208 }
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
209
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
210 idx_str = g_utf8_strchr(idx_str, -1, character);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
211 if(idx_str == NULL) {
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
212 g_free(cmp_pattern);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
213 g_free(cmp_str);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
214
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
215 return FALSE;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
216 }
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
217
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
218 /* We found the current character in pattern, so move to the next. */
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
219 idx_pattern = g_utf8_next_char(idx_pattern);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
220
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
221 /* move idx_str to the next character as well, because the current
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
222 * character has already been matched.
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
223 */
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
224 idx_str = g_utf8_next_char(idx_str);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
225 };
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
226
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
227 g_free(cmp_pattern);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
228 g_free(cmp_str);
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
229
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
230 return TRUE;
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
231 }
d55b605fdafb Add purple_strmatches and move purple_person_matches and purple_contact_info_matches to it
Gary Kramlich <grim@reaperworld.com>
parents: 41882
diff changeset
232
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
233 /**************************************************************************
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
234 * URI/URL Functions
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
235 **************************************************************************/
15678
7434ef155a3a Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <datallah@pidgin.im>
parents: 15482
diff changeset
236
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
237 /* Originally lifted from
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
238 * http://www.oreillynet.com/pub/a/network/excerpt/spcookbook_chap03/index3.html
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
239 * ... and slightly modified to be a bit more rfc822 compliant
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
240 * ... and modified a bit more to make domain checking rfc1035 compliant
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
241 * with the exception permitted in rfc1101 for domains to start with digit
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
242 * but not completely checking to avoid conflicts with IP addresses
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
243 */
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
244 gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
245 purple_email_is_valid(const char *address)
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
246 {
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
247 const char *c, *domain;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
248 static char *rfc822_specials = "()<>@,;:\\\"[]";
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
249
24645
da3a357c07c1 Fix CID #385
Richard Laager <rlaager@pidgin.im>
parents: 24644
diff changeset
250 g_return_val_if_fail(address != NULL, FALSE);
da3a357c07c1 Fix CID #385
Richard Laager <rlaager@pidgin.im>
parents: 24644
diff changeset
251
30444
d871c3fd6637 Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 30437
diff changeset
252 if (*address == '.') return FALSE;
d871c3fd6637 Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 30437
diff changeset
253
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
254 /* first we validate the name portion (name@domain) (rfc822)*/
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
255 for (c = address; *c; c++) {
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
256 if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == '\"')) {
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
257 while (*++c) {
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
258 if (*c == '\\') {
38922
9f05d7f41a53 purple_email_is_valid: fix out of bounds read
dx <dx@dxzone.com.ar>
parents: 38737
diff changeset
259 if (*c++ && *c < 127 && *c > 0 && *c != '\n' && *c != '\r') continue;
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
260 else return FALSE;
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
261 }
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
262 if (*c == '\"') break;
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
263 if (*c < ' ' || *c >= 127) return FALSE;
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
264 }
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
265 if (!*c++) return FALSE;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
266 if (*c == '@') break;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
267 if (*c != '.') return FALSE;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
268 continue;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
269 }
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
270 if (*c == '@') break;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
271 if (*c <= ' ' || *c >= 127) return FALSE;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
272 if (strchr(rfc822_specials, *c)) return FALSE;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
273 }
18871
078df6ae587a Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <markdoliner@pidgin.im>
parents: 18813
diff changeset
274
078df6ae587a Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <markdoliner@pidgin.im>
parents: 18813
diff changeset
275 /* It's obviously not an email address if we didn't find an '@' above */
078df6ae587a Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <markdoliner@pidgin.im>
parents: 18813
diff changeset
276 if (*c == '\0') return FALSE;
078df6ae587a Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <markdoliner@pidgin.im>
parents: 18813
diff changeset
277
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
278 /* strictly we should return false if (*(c - 1) == '.') too, but I think
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
279 * we should permit user.@domain type addresses - they do work :) */
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
280 if (c == address) return FALSE;
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
281
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
282 /* next we validate the domain portion (name@domain) (rfc1035 & rfc1011) */
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
283 if (!*(domain = ++c)) return FALSE;
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
284 do {
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
285 if (*c == '.' && (c == domain || *(c - 1) == '.' || *(c - 1) == '-'))
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
286 return FALSE;
30444
d871c3fd6637 Catch some more invalid email addresses, thanks to Mark for additional
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 30437
diff changeset
287 if (*c == '-' && (*(c - 1) == '.' || *(c - 1) == '@')) return FALSE;
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
288 if ((*c < '0' && *c != '-' && *c != '.') || (*c > '9' && *c < 'A') ||
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
289 (*c > 'Z' && *c < 'a') || (*c > 'z')) return FALSE;
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
290 } while (*++c);
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
291
9054
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
292 if (*(c - 1) == '-') return FALSE;
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
293
481fddb7dc5a [gaim-migrate @ 9830]
Tim Ringenbach <marv@pidgin.im>
parents: 9045
diff changeset
294 return ((c - domain) > 3 ? TRUE : FALSE);
9045
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
295 }
c665ceb89b85 [gaim-migrate @ 9821]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8976
diff changeset
296
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
297 /**************************************************************************
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
298 * UTF8 String Functions
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
299 **************************************************************************/
9642
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
300 gchar *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
301 purple_utf8_try_convert(const char *str)
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
302 {
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
303 gsize converted;
9642
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
304 gchar *utf8;
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
305
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
306 g_return_val_if_fail(str != NULL, NULL);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
307
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
308 if (g_utf8_validate(str, -1, NULL)) {
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
309 return g_strdup(str);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
310 }
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
311
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
312 utf8 = g_locale_to_utf8(str, -1, &converted, NULL, NULL);
9642
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
313 if (utf8 != NULL)
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
314 return utf8;
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
315
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
316 utf8 = g_convert(str, -1, "UTF-8", "ISO-8859-15", &converted, NULL, NULL);
9642
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
317 if ((utf8 != NULL) && (converted == strlen(str)))
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
318 return utf8;
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
319
14097
0c340861ab79 [gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents: 14002
diff changeset
320 g_free(utf8);
9642
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
321
ec0b88cf9161 [gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents: 9427
diff changeset
322 return NULL;
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
323 }
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
324
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
325 int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
326 purple_utf8_strcasecmp(const char *a, const char *b)
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
327 {
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
328 char *a_norm = NULL;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
329 char *b_norm = NULL;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
330 int ret = -1;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
331
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
332 if(!a && b)
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
333 return -1;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
334 else if(!b && a)
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
335 return 1;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
336 else if(!a && !b)
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
337 return 0;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
338
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
339 if(!g_utf8_validate(a, -1, NULL) || !g_utf8_validate(b, -1, NULL))
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
340 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
341 purple_debug_error("purple_utf8_strcasecmp",
7108
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
342 "One or both parameters are invalid UTF8\n");
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
343 return ret;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
344 }
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
345
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
346 a_norm = g_utf8_casefold(a, -1);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
347 b_norm = g_utf8_casefold(b, -1);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
348 ret = g_utf8_collate(a_norm, b_norm);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
349 g_free(a_norm);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
350 g_free(b_norm);
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
351
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
352 return ret;
82655fa54acb [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
353 }
7162
dfd30c70acde [gaim-migrate @ 7729]
Nathan Walp <nwalp@pidgin.im>
parents: 7134
diff changeset
354
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
355 /* this is almost identical to purple_url_encode (hence purple_url_decode
9926
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
356 * being used above), but we want to keep certain characters unescaped
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
357 * for compat reasons */
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
358 const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15845
diff changeset
359 purple_escape_filename(const char *str)
9926
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
360 {
10700
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
361 const char *iter;
9926
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
362 static char buf[BUF_LEN];
10700
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
363 char utf_char[6];
9926
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
364 guint i, j = 0;
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
365
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
366 g_return_val_if_fail(str != NULL, NULL);
10700
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
367 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL);
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
368
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
369 iter = str;
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
370 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) {
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
371 gunichar c = g_utf8_get_char(iter);
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
372 /* If the character is an ASCII character and is alphanumeric,
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
373 * or one of the specified values, no need to escape */
17261
65aa3164dcce If we're operating on ASCII characters only, we should use g_ascii_isalnum.
Richard Laager <rlaager@pidgin.im>
parents: 17254
diff changeset
374 if (c < 128 && (g_ascii_isalnum(c) || c == '@' || c == '-' ||
10700
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
375 c == '_' || c == '.' || c == '#')) {
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
376 buf[j++] = c;
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
377 } else {
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
378 int bytes = g_unichar_to_utf8(c, utf_char);
36256
a437550a9308 Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 36037
diff changeset
379 for (i = 0; (int)i < bytes; i++) {
10700
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
380 if (j > (BUF_LEN - 4))
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
381 break;
36037
e2ef692ff10a Fix outstaning Coverity bugs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36030
diff changeset
382 if (i >= sizeof(utf_char)) {
e2ef692ff10a Fix outstaning Coverity bugs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36030
diff changeset
383 g_warn_if_reached();
e2ef692ff10a Fix outstaning Coverity bugs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36030
diff changeset
384 break;
e2ef692ff10a Fix outstaning Coverity bugs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36030
diff changeset
385 }
10700
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
386 sprintf(buf + j, "%%%02x", utf_char[i] & 0xff);
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
387 j += 3;
93f5099b2775 [gaim-migrate @ 12273]
Daniel Atallah <datallah@pidgin.im>
parents: 10636
diff changeset
388 }
9926
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
389 }
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
390 }
30414
b334269e9ecf Apparently file/directory names in windows cannot end in periods/spaces.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30413
diff changeset
391 #ifdef _WIN32
b334269e9ecf Apparently file/directory names in windows cannot end in periods/spaces.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30413
diff changeset
392 /* File/Directory names in windows cannot end in periods/spaces.
b334269e9ecf Apparently file/directory names in windows cannot end in periods/spaces.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30413
diff changeset
393 * http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx
b334269e9ecf Apparently file/directory names in windows cannot end in periods/spaces.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30413
diff changeset
394 */
b334269e9ecf Apparently file/directory names in windows cannot end in periods/spaces.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30413
diff changeset
395 while (j > 0 && (buf[j - 1] == '.' || buf[j - 1] == ' '))
b334269e9ecf Apparently file/directory names in windows cannot end in periods/spaces.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30413
diff changeset
396 j--;
b334269e9ecf Apparently file/directory names in windows cannot end in periods/spaces.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30413
diff changeset
397 #endif
9926
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
398 buf[j] = '\0';
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
399
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
400 return buf;
9957e01fd88a [gaim-migrate @ 10818]
Nathan Walp <nwalp@pidgin.im>
parents: 9916
diff changeset
401 }

mercurial