1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
diff -urNad gnome-utils-2.14.0~/gnome-dictionary/libgdict/Makefile.am gnome-utils-2.14.0/gnome-dictionary/libgdict/Makefile.am
--- gnome-dictionary/libgdict/Makefile.am 2006-01-12 04:39:01.000000000 +0100
+++ gnome-dictionary/libgdict/Makefile.am 2006-05-07 12:44:29.000000000 +0200
@@ -2,6 +2,9 @@
NULL =
+# remove comment to enable debugging
+#GDICT_ENABLE_DEBUG=-DGDICT_ENABLE_DEBUG=1
+
INCLUDES = -DG_LOG_DOMAIN=\"Gdict\" \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\" \
@@ -10,6 +13,7 @@
-DGNOMELOCALEDIR=\""$(gnomeutilslocaledir)"\" \
-DGDICTSOURCESDIR=\""$(datadir)/gdict-1.0/sources"\" \
-DGDICT_ENABLE_INTERNALS=1 \
+ $(GDICT_ENABLE_DEBUG) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(WARN_CFLAGS) \
$(NULL)
diff -urNad gnome-utils-2.14.0~/gnome-dictionary/libgdict/gdict-client-context.c gnome-utils-2.14.0/gnome-dictionary/libgdict/gdict-client-context.c
--- gnome-dictionary/libgdict/gdict-client-context.c 2006-02-11 17:55:02.000000000 +0100
+++ gnome-dictionary/libgdict/gdict-client-context.c 2006-05-07 12:44:47.000000000 +0200
@@ -1629,10 +1629,11 @@
/* retrieve the status code from the server response line */
static gint
-get_status_code (const gchar *line)
+get_status_code (const gchar *line,
+ gint old_status)
{
gchar *status;
- gint retval;
+ gint possible_status, retval;
if (strlen (line) < 3)
return 0;
@@ -1641,14 +1642,47 @@
!g_unichar_isdigit (line[1]) ||
!g_unichar_isdigit (line[2]))
return 0;
+
+ if (!g_unichar_isspace (line[3]))
+ return 0;
status = g_strndup (line, 3);
- retval = atoi (status);
+ possible_status = atoi (status);
g_free (status);
+
+ /* status whitelisting: sometimes, a database *cough* moby-thes *cough*
+ * might return a number as first word; we do a small check here for
+ * invalid status codes based on the previously set status; we don't check
+ * the whole line, as we need only to be sure that the status code is
+ * consistent with what we expect.
+ */
+ switch (old_status)
+ {
+ case GDICT_STATUS_WORD_DB_NAME:
+ if (possible_status == GDICT_STATUS_OK)
+ retval = possible_status;
+ else
+ retval = 0;
+ break;
+ case GDICT_STATUS_N_DEFINITIONS_RETRIEVED:
+ if (possible_status == GDICT_STATUS_WORD_DB_NAME)
+ retval = possible_status;
+ else
+ retval = 0;
+ break;
+ case GDICT_STATUS_N_MATCHES_FOUND:
+ if (possible_status == GDICT_STATUS_OK)
+ retval = possible_status;
+ else
+ retval = 0;
+ break;
+ default:
+ retval = possible_status;
+ break;
+ }
return retval;
}
-
static gboolean
gdict_client_context_io_watch_cb (GIOChannel *channel,
@@ -1735,7 +1769,7 @@
/* truncate the line terminator before parsing */
line[term] = '\0';
- status_code = get_status_code (line);
+ status_code = get_status_code (line, priv->status_code);
if ((status_code == 0) || (GDICT_IS_VALID_STATUS_CODE (status_code)))
{
priv->status_code = status_code;
|