Hello community,

here is the log from the commit of package weechat for openSUSE:Factory checked 
in at 2012-11-20 10:50:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/weechat (Old)
 and      /work/SRC/openSUSE:Factory/.weechat.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "weechat", Maintainer is ""

Changes:
--------
--- /work/SRC/openSUSE:Factory/weechat/weechat.changes  2012-11-12 
07:07:58.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.weechat.new/weechat.changes     2012-11-20 
10:50:55.000000000 +0100
@@ -1,0 +2,7 @@
+Mon Nov 19 09:35:38 UTC 2012 - [email protected]
+
+- update to version 0.3.9.2:
+  * fix possible shell injection vulnerability in hook_process
+    function (bnc#790217)
+
+-------------------------------------------------------------------

Old:
----
  weechat-0.3.9.1.tar.bz2

New:
----
  weechat-0.3.9.2.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ weechat.spec ++++++
--- /var/tmp/diff_new_pack.IMyGVm/_old  2012-11-20 10:50:56.000000000 +0100
+++ /var/tmp/diff_new_pack.IMyGVm/_new  2012-11-20 10:50:56.000000000 +0100
@@ -20,7 +20,7 @@
 %endif
 
 Name:           weechat
-Version:        0.3.9.1
+Version:        0.3.9.2
 Release:        0
 Summary:        Portable, Fast, Light and Extensible Chat Client
 License:        GPL-3.0+

++++++ weechat-0.3.9.1.tar.bz2 -> weechat-0.3.9.2.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/CMakeLists.txt 
new/weechat-0.3.9.2/CMakeLists.txt
--- old/weechat-0.3.9.1/CMakeLists.txt  2012-11-09 18:28:23.000000000 +0100
+++ new/weechat-0.3.9.2/CMakeLists.txt  2012-11-18 10:50:33.000000000 +0100
@@ -33,7 +33,7 @@
 
 SET(VERSION_MAJOR "0")
 SET(VERSION_MINOR "3")
-SET(VERSION_PATCH "9.1")
+SET(VERSION_PATCH "9.2")
 SET(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
 SET(LICENSE "GPL3")
 SET(PKG_STRING "${PROJECT_NAME} ${VERSION}")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/ChangeLog 
new/weechat-0.3.9.2/ChangeLog
--- old/weechat-0.3.9.1/ChangeLog       2012-11-09 18:22:44.000000000 +0100
+++ new/weechat-0.3.9.2/ChangeLog       2012-11-18 11:19:30.000000000 +0100
@@ -1,9 +1,15 @@
 WeeChat ChangeLog
 =================
 Sébastien Helleu <[email protected]>
-v0.3.9.1, 2012-11-09
+v0.3.9.2, 2012-11-18
 
 
+Version 0.3.9.2 (2012-11-18)
+----------------------------
+
+* core: do not call shell to execute command in hook_process (fix security
+  problem when a plugin/script gives untrusted command) (bug #37764)
+
 Version 0.3.9.1 (2012-11-09)
 ----------------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/NEWS new/weechat-0.3.9.2/NEWS
--- old/weechat-0.3.9.1/NEWS    2012-11-09 18:24:41.000000000 +0100
+++ new/weechat-0.3.9.2/NEWS    2012-11-18 11:19:36.000000000 +0100
@@ -1,9 +1,15 @@
 WeeChat Release Notes
 =====================
 Sébastien Helleu <[email protected]>
-v0.3.9.1, 2012-11-09
+v0.3.9.2, 2012-11-18
 
 
+Version 0.3.9.2 (2012-11-18)
+----------------------------
+
+This version fixes a security vulnerability when a plugin/script gives 
untrusted
+command to API function "hook_process".
+
 Version 0.3.9.1 (2012-11-09)
 ----------------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/configure 
new/weechat-0.3.9.2/configure
--- old/weechat-0.3.9.1/configure       2012-11-09 18:44:16.000000000 +0100
+++ new/weechat-0.3.9.2/configure       2012-11-18 11:29:15.000000000 +0100
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for WeeChat 0.3.9.1.
+# Generated by GNU Autoconf 2.69 for WeeChat 0.3.9.2.
 #
 # Report bugs to <[email protected]>.
 #
@@ -590,8 +590,8 @@
 # Identity of this package.
 PACKAGE_NAME='WeeChat'
 PACKAGE_TARNAME='weechat'
-PACKAGE_VERSION='0.3.9.1'
-PACKAGE_STRING='WeeChat 0.3.9.1'
+PACKAGE_VERSION='0.3.9.2'
+PACKAGE_STRING='WeeChat 0.3.9.2'
 PACKAGE_BUGREPORT='[email protected]'
 PACKAGE_URL=''
 
@@ -1483,7 +1483,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures WeeChat 0.3.9.1 to adapt to many kinds of systems.
+\`configure' configures WeeChat 0.3.9.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1553,7 +1553,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of WeeChat 0.3.9.1:";;
+     short | recursive ) echo "Configuration of WeeChat 0.3.9.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1699,7 +1699,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-WeeChat configure 0.3.9.1
+WeeChat configure 0.3.9.2
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2305,7 +2305,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by WeeChat $as_me 0.3.9.1, which was
+It was created by WeeChat $as_me 0.3.9.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3126,7 +3126,7 @@
 
 # Define the identity of the package.
  PACKAGE=weechat
- VERSION=0.3.9.1
+ VERSION=0.3.9.2
 
 
 cat >>confdefs.h <<_ACEOF
@@ -20034,7 +20034,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by WeeChat $as_me 0.3.9.1, which was
+This file was extended by WeeChat $as_me 0.3.9.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20100,7 +20100,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-WeeChat config.status 0.3.9.1
+WeeChat config.status 0.3.9.2
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/configure.in 
new/weechat-0.3.9.2/configure.in
--- old/weechat-0.3.9.1/configure.in    2012-11-09 18:28:33.000000000 +0100
+++ new/weechat-0.3.9.2/configure.in    2012-11-18 10:50:21.000000000 +0100
@@ -24,10 +24,10 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.56)
-AC_INIT(WeeChat, 0.3.9.1, [email protected])
+AC_INIT(WeeChat, 0.3.9.2, [email protected])
 AC_CONFIG_SRCDIR([src/core/weechat.c])
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE([weechat], [0.3.9.1])
+AM_INIT_AUTOMAKE([weechat], [0.3.9.2])
 LICENSE="GPL3"
 
 # Checks for programs
Files old/weechat-0.3.9.1/po/cs.gmo and new/weechat-0.3.9.2/po/cs.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/cs.po new/weechat-0.3.9.2/po/cs.po
--- old/weechat-0.3.9.1/po/cs.po        2012-11-09 18:36:08.000000000 +0100
+++ new/weechat-0.3.9.2/po/cs.po        2012-11-18 10:51:08.000000000 +0100
@@ -18,10 +18,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Jiri Golembiovsky <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: Czech\n"
Files old/weechat-0.3.9.1/po/de.gmo and new/weechat-0.3.9.2/po/de.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/de.po new/weechat-0.3.9.2/po/de.po
--- old/weechat-0.3.9.1/po/de.po        2012-11-09 18:36:13.000000000 +0100
+++ new/weechat-0.3.9.2/po/de.po        2012-11-18 10:51:15.000000000 +0100
@@ -21,10 +21,10 @@
 # nils, 2012.
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Nils Görs <[email protected]>\n"
 "Language-Team: German <[email protected]>\n"
 "Language: \n"
Files old/weechat-0.3.9.1/po/es.gmo and new/weechat-0.3.9.2/po/es.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/es.po new/weechat-0.3.9.2/po/es.po
--- old/weechat-0.3.9.1/po/es.po        2012-11-09 18:36:17.000000000 +0100
+++ new/weechat-0.3.9.2/po/es.po        2012-11-18 10:51:20.000000000 +0100
@@ -20,10 +20,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Elián Hanisch <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: Spanish\n"
Files old/weechat-0.3.9.1/po/fr.gmo and new/weechat-0.3.9.2/po/fr.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/fr.po new/weechat-0.3.9.2/po/fr.po
--- old/weechat-0.3.9.1/po/fr.po        2012-11-09 18:36:22.000000000 +0100
+++ new/weechat-0.3.9.2/po/fr.po        2012-11-18 10:51:26.000000000 +0100
@@ -19,10 +19,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Sebastien Helleu <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: French\n"
Files old/weechat-0.3.9.1/po/hu.gmo and new/weechat-0.3.9.2/po/hu.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/hu.po new/weechat-0.3.9.2/po/hu.po
--- old/weechat-0.3.9.1/po/hu.po        2012-11-09 18:36:27.000000000 +0100
+++ new/weechat-0.3.9.2/po/hu.po        2012-11-18 10:51:31.000000000 +0100
@@ -18,10 +18,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Andras Voroskoi <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: Hungarian\n"
Files old/weechat-0.3.9.1/po/it.gmo and new/weechat-0.3.9.2/po/it.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/it.po new/weechat-0.3.9.2/po/it.po
--- old/weechat-0.3.9.1/po/it.po        2012-11-09 18:36:31.000000000 +0100
+++ new/weechat-0.3.9.2/po/it.po        2012-11-18 10:51:36.000000000 +0100
@@ -18,10 +18,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Marco Paolone <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: Italian\n"
Files old/weechat-0.3.9.1/po/ja.gmo and new/weechat-0.3.9.2/po/ja.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/ja.po new/weechat-0.3.9.2/po/ja.po
--- old/weechat-0.3.9.1/po/ja.po        2012-11-09 18:36:35.000000000 +0100
+++ new/weechat-0.3.9.2/po/ja.po        2012-11-18 10:51:41.000000000 +0100
@@ -18,10 +18,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: AYANOKOUZI, Ryuunosuke <[email protected]>\n"
 "Language-Team: Japanese <https://github.com/l/WeeChat>\n"
 "Language: ja\n"
Files old/weechat-0.3.9.1/po/pl.gmo and new/weechat-0.3.9.2/po/pl.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/pl.po new/weechat-0.3.9.2/po/pl.po
--- old/weechat-0.3.9.1/po/pl.po        2012-11-09 18:44:31.000000000 +0100
+++ new/weechat-0.3.9.2/po/pl.po        2012-11-18 11:29:31.000000000 +0100
@@ -19,10 +19,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Krzysztof Korościk <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: Polish\n"
Files old/weechat-0.3.9.1/po/pt_BR.gmo and new/weechat-0.3.9.2/po/pt_BR.gmo 
differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/pt_BR.po 
new/weechat-0.3.9.2/po/pt_BR.po
--- old/weechat-0.3.9.1/po/pt_BR.po     2012-11-09 18:36:43.000000000 +0100
+++ new/weechat-0.3.9.2/po/pt_BR.po     2012-11-18 10:51:50.000000000 +0100
@@ -19,10 +19,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Sergio Durigan Junior <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: Portuguese\n"
Files old/weechat-0.3.9.1/po/ru.gmo and new/weechat-0.3.9.2/po/ru.gmo differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/po/ru.po new/weechat-0.3.9.2/po/ru.po
--- old/weechat-0.3.9.1/po/ru.po        2012-11-09 18:44:31.000000000 +0100
+++ new/weechat-0.3.9.2/po/ru.po        2012-11-18 11:29:31.000000000 +0100
@@ -19,10 +19,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: WeeChat 0.3.9.1\n"
+"Project-Id-Version: WeeChat 0.3.9.2\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
 "POT-Creation-Date: 2012-09-29 09:37+0200\n"
-"PO-Revision-Date: 2012-11-09 18:36+0100\n"
+"PO-Revision-Date: 2012-11-18 10:51+0100\n"
 "Last-Translator: Aleksey V Zapparov AKA ixti <[email protected]>\n"
 "Language-Team: weechat-dev <[email protected]>\n"
 "Language: Russian\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/src/core/wee-hook.c 
new/weechat-0.3.9.2/src/core/wee-hook.c
--- old/weechat-0.3.9.1/src/core/wee-hook.c     2012-11-09 18:20:10.000000000 
+0100
+++ new/weechat-0.3.9.2/src/core/wee-hook.c     2012-11-18 10:42:33.000000000 
+0100
@@ -1387,9 +1387,9 @@
 void
 hook_process_child (struct t_hook *hook_process)
 {
-    char *exec_args[4] = { "sh", "-c", NULL, NULL };
+    char **exec_args;
     const char *ptr_url;
-    int rc;
+    int rc, i;
 
     /*
      * close stdin, so that process will fail to read stdin (process reading
@@ -1428,10 +1428,24 @@
     else
     {
         /* launch command */
-        exec_args[2] = HOOK_PROCESS(hook_process, command);
-        execvp (exec_args[0], exec_args);
+        exec_args = string_split_shell (HOOK_PROCESS(hook_process, command));
+        if (exec_args)
+        {
+            if (weechat_debug_core >= 1)
+            {
+                log_printf ("hook_process, command='%s'",
+                            HOOK_PROCESS(hook_process, command));
+                for (i = 0; exec_args[i]; i++)
+                {
+                    log_printf ("  args[%02d] == '%s'", i, exec_args[i]);
+                }
+            }
+            execvp (exec_args[0], exec_args);
+        }
 
         /* should not be executed if execvp was ok */
+        if (exec_args)
+            string_free_split (exec_args);
         fprintf (stderr, "Error with command '%s'\n",
                  HOOK_PROCESS(hook_process, command));
         rc = EXIT_FAILURE;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/src/core/wee-string.c 
new/weechat-0.3.9.2/src/core/wee-string.c
--- old/weechat-0.3.9.1/src/core/wee-string.c   2012-11-09 18:20:10.000000000 
+0100
+++ new/weechat-0.3.9.2/src/core/wee-string.c   2012-11-18 10:42:33.000000000 
+0100
@@ -1139,6 +1139,196 @@
 }
 
 /*
+ * string_split_shell: split a string like the shell does for a command with
+ *                     arguments.
+ *                     Note: result must be freed with string_free_split.
+ *                     This function is a C conversion of python class "shlex"
+ *                     (file: Lib/shlex.py in python repository)
+ *                     Doc: http://docs.python.org/3/library/shlex.html
+ *                     Copyrights in shlex.py:
+ *                       Module and documentation by Eric S. Raymond, 21 Dec 
1998
+ *                       Input stacking and error message cleanup added by 
ESR, March 2000
+ *                       push_source() and pop_source() made explicit by ESR, 
January 2001.
+ *                       Posix compliance, split(), string arguments, and
+ *                       iterator interface by Gustavo Niemeyer, April 2003.
+ */
+
+char **
+string_split_shell (const char *string)
+{
+    int temp_len, num_args, add_char_to_temp, add_temp_to_args, quoted;
+    char *string2, *temp, **args, **args2, state, escapedstate;
+    char *ptr_string, *ptr_next, saved_char;
+
+    if (!string)
+        return NULL;
+
+    string2 = strdup (string);
+    if (!string2)
+        return NULL;
+
+    /*
+     * prepare "args" with one pointer to NULL, the "args" will be reallocated
+     * later, each time a new argument is added
+     */
+    num_args = 0;
+    args = malloc ((num_args + 1) * sizeof (args[0]));
+    if (!args)
+    {
+        free (string2);
+        return NULL;
+    }
+    args[0] = NULL;
+
+    /* prepare a temp string for working (adding chars one by one) */
+    temp = malloc ((2 * strlen (string)) + 1);
+    if (!temp)
+    {
+        free (string2);
+        free (args);
+        return NULL;
+    }
+    temp[0] = '\0';
+    temp_len = 0;
+
+    state = ' ';
+    escapedstate = ' ';
+    quoted = 0;
+    ptr_string = string2;
+    while (ptr_string[0])
+    {
+        add_char_to_temp = 0;
+        add_temp_to_args = 0;
+        ptr_next = utf8_next_char (ptr_string);
+        saved_char = ptr_next[0];
+        ptr_next[0] = '\0';
+        if (state == ' ')
+        {
+            if ((ptr_string[0] == ' ') || (ptr_string[0] == '\t')
+                || (ptr_string[0] == '\r') || (ptr_string[0] == '\n'))
+            {
+                if (temp[0] || quoted)
+                    add_temp_to_args = 1;
+            }
+            else if (ptr_string[0] == '\\')
+            {
+                escapedstate = 'a';
+                state = ptr_string[0];
+            }
+            else if ((ptr_string[0] == '\'') || (ptr_string[0] == '"'))
+            {
+                state = ptr_string[0];
+            }
+            else
+            {
+                add_char_to_temp = 1;
+                state = 'a';
+            }
+        }
+        else if ((state == '\'') || (state == '"'))
+        {
+            quoted = 1;
+            if (ptr_string[0] == state)
+            {
+                state = 'a';
+            }
+            else if ((state == '"') && (ptr_string[0] == '\\'))
+            {
+                escapedstate = state;
+                state = ptr_string[0];
+            }
+            else
+            {
+                add_char_to_temp = 1;
+            }
+        }
+        else if (state == '\\')
+        {
+            if (((escapedstate == '\'') || (escapedstate == '"'))
+                && (ptr_string[0] != state) && (ptr_string[0] != escapedstate))
+            {
+                temp[temp_len] = state;
+                temp_len++;
+                temp[temp_len] = '\0';
+            }
+            add_char_to_temp = 1;
+            state = escapedstate;
+        }
+        else if (state == 'a')
+        {
+            if ((ptr_string[0] == ' ') || (ptr_string[0] == '\t')
+                || (ptr_string[0] == '\r') || (ptr_string[0] == '\n'))
+            {
+                state = ' ';
+                if (temp[0] || quoted)
+                    add_temp_to_args = 1;
+            }
+            else if (ptr_string[0] == '\\')
+            {
+                escapedstate = 'a';
+                state = ptr_string[0];
+            }
+            else if ((ptr_string[0] == '\'') || (ptr_string[0] == '"'))
+            {
+                state = ptr_string[0];
+            }
+            else
+            {
+                add_char_to_temp = 1;
+            }
+        }
+        if (add_char_to_temp)
+        {
+            memcpy (temp + temp_len, ptr_string, ptr_next - ptr_string);
+            temp_len += (ptr_next - ptr_string);
+            temp[temp_len] = '\0';
+        }
+        if (add_temp_to_args)
+        {
+            num_args++;
+            args2 = realloc (args, (num_args + 1) * sizeof (args[0]));
+            if (!args2)
+            {
+                free (string2);
+                free (temp);
+                return args;
+            }
+            args = args2;
+            args[num_args - 1] = strdup (temp);
+            args[num_args] = NULL;
+            temp[0] = '\0';
+            temp_len = 0;
+            escapedstate = ' ';
+            quoted = 0;
+        }
+        ptr_next[0] = saved_char;
+        ptr_string = ptr_next;
+    }
+
+    if (temp[0] || (state != ' '))
+    {
+        num_args++;
+        args2 = realloc (args, (num_args + 1) * sizeof (args[0]));
+        if (!args2)
+        {
+            free (string2);
+            free (temp);
+            return args;
+        }
+        args = args2;
+        args[num_args - 1] = strdup (temp);
+        args[num_args] = NULL;
+        temp[0] = '\0';
+        temp_len = 0;
+    }
+
+    free (string2);
+    free (temp);
+
+    return args;
+}
+
+/*
  * string_free_split: free a split string
  */
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/src/core/wee-string.h 
new/weechat-0.3.9.2/src/core/wee-string.h
--- old/weechat-0.3.9.1/src/core/wee-string.h   2012-11-09 18:20:10.000000000 
+0100
+++ new/weechat-0.3.9.2/src/core/wee-string.h   2012-11-18 10:42:33.000000000 
+0100
@@ -59,6 +59,7 @@
 extern int string_has_highlight_regex (const char *string, const char *regex);
 extern char **string_split (const char *string, const char *separators,
                             int keep_eol, int num_items_max, int *num_items);
+extern char **string_split_shell (const char *string);
 extern void string_free_split (char **split_string);
 extern char *string_build_with_split_string (const char **split_string,
                                              const char *separator);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/weechat-0.3.9.1/weechat.spec 
new/weechat-0.3.9.2/weechat.spec
--- old/weechat-0.3.9.1/weechat.spec    2012-11-09 18:35:10.000000000 +0100
+++ new/weechat-0.3.9.2/weechat.spec    2012-11-18 11:19:13.000000000 +0100
@@ -23,7 +23,7 @@
 #
 
 %define name weechat
-%define version 0.3.9.1
+%define version 0.3.9.2
 %define release 1
 
 Name:      %{name}
@@ -73,6 +73,8 @@
 %{_includedir}/%{name}/weechat-plugin.h
 
 %changelog
+* Sun Nov 18 2012 Sebastien Helleu <[email protected]> 0.3.9.2-1
+- Released version 0.3.9.2
 * Fri Nov 09 2012 Sebastien Helleu <[email protected]> 0.3.9.1-1
 - Released version 0.3.9.1
 * Sat Sep 29 2012 Sebastien Helleu <[email protected]> 0.3.9-1

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to