Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
773e82a2
Commit
773e82a2
authored
14 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#3619] Add single quote escapement function
parent
61c125b9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-client-gnome/src/widget/imwidget.c
+50
-15
50 additions, 15 deletions
sflphone-client-gnome/src/widget/imwidget.c
with
50 additions
and
15 deletions
sflphone-client-gnome/src/widget/imwidget.c
+
50
−
15
View file @
773e82a2
...
...
@@ -41,24 +41,59 @@ on_frame_loading_done (GObject *gobject, GParamSpec *pspec, gpointer user_data)
IMWidget
*
im
=
IM_WIDGET
(
user_data
);
callable_obj_t
*
c
;
switch
(
webkit_web_frame_get_load_status
(
WEBKIT_WEB_FRAME
(
im
->
web_frame
)))
{
case
WEBKIT_LOAD_PROVISIONAL
:
case
WEBKIT_LOAD_COMMITTED
:
break
;
case
WEBKIT_LOAD_FINISHED
:
c
=
calllist_get
(
current_calls
,
im
->
call_id
);
im_widget_add_message
(
im
,
get_peer_information
(
c
),
im
->
first_message
,
0
);
g_free
(
im
->
first_message
);
im
->
first_message
=
NULL
;
DEBUG
(
"JavaScrip loading frame finished"
);
break
;
case
WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
:
case
WEBKIT_LOAD_FAILED
:
break
;
if
(
im
->
first_message
)
{
switch
(
webkit_web_frame_get_load_status
(
WEBKIT_WEB_FRAME
(
im
->
web_frame
)))
{
case
WEBKIT_LOAD_PROVISIONAL
:
case
WEBKIT_LOAD_COMMITTED
:
break
;
case
WEBKIT_LOAD_FINISHED
:
c
=
calllist_get
(
current_calls
,
im
->
call_id
);
im_widget_add_message
(
im
,
get_peer_information
(
c
),
im
->
first_message
,
0
);
g_free
(
im
->
first_message
);
im
->
first_message
=
NULL
;
DEBUG
(
"JavaScrip loading frame finished"
);
break
;
case
WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
:
case
WEBKIT_LOAD_FAILED
:
break
;
}
}
}
gchar
*
escape_single_quotes
(
gchar
*
message
)
{
gchar
**
ptr_token
;
gchar
*
string
;
DEBUG
(
"message: %s"
,
message
);
if
(
ptr_token
=
g_strsplit
(
message
,
"'"
,
NULL
))
{
string
=
*
ptr_token
;
ptr_token
++
;
DEBUG
(
"SPLITTING"
);
// string = g_strjoinv ("\\'", ptr_token);
while
(
*
ptr_token
)
{
DEBUG
(
"tokens: %s"
,
*
ptr_token
);
// if (g_strcmp0 (string[ (strlen (string)-1) ], "\\") == 0) {
// DEBUG ("already escaped last character %s", string[ (strlen (string)-1) ]);
// string = g_strdup_printf ("%s'%s", string, *ptr_token);
// } else
string
=
g_strdup_printf
(
"%s
\\
'%s"
,
string
,
*
ptr_token
);
ptr_token
++
;
}
}
DEBUG
(
"string: %s"
,
string
);
return
string
;
}
void
im_widget_add_message
(
IMWidget
*
im
,
const
gchar
*
from
,
const
gchar
*
message
,
gint
level
)
{
...
...
@@ -73,7 +108,7 @@ im_widget_add_message (IMWidget *im, const gchar *from, const gchar *message, gi
gchar
*
css_class
=
(
level
==
MESSAGE_LEVEL_ERROR
)
?
"error"
:
""
;
/* Prepare and execute the Javascript code */
gchar
*
script
=
g_strdup_printf
(
"add_message('%s', '%s', '%s', '%s');"
,
message
,
from
,
css_class
,
msgtime
);
gchar
*
script
=
g_strdup_printf
(
"add_message('%s', '%s', '%s', '%s');"
,
escape_single_quotes
(
message
)
,
from
,
css_class
,
msgtime
);
webkit_web_view_execute_script
(
WEBKIT_WEB_VIEW
(
im
->
web_view
),
script
);
/* Cleanup */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment