From 385e0d5ccf710c67a614ae66f4ce252c1aea8660 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Sun, 12 Jan 2014 18:49:02 +0200 Subject: [PATCH 1/6] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bfa19100e8e..d861c4d03d5 100644 --- a/.gitignore +++ b/.gitignore @@ -481,3 +481,4 @@ ext/mvc/model/query/lemon ext/mvc/model/query/parser.out ext/mvc/view/engine/volt/lemon ext/mvc/view/engine/volt/parser.out +*.d From 1be335cabc153800d732a1e075dad40ee5e1e40d Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Mon, 13 Jan 2014 02:00:01 +0200 Subject: [PATCH 2/6] Fix #1783 --- ext/mvc/collection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mvc/collection.c b/ext/mvc/collection.c index b0f3aefc287..136fe943d86 100644 --- a/ext/mvc/collection.c +++ b/ext/mvc/collection.c @@ -1407,7 +1407,7 @@ PHP_METHOD(Phalcon_Mvc_Collection, save){ MAKE_STD_ZVAL(options); Z_SET_REFCOUNT_P(options, 0); /* will be automatically destroyed by Zend on return from method call */ array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); /** * Save the document @@ -1941,7 +1941,7 @@ PHP_METHOD(Phalcon_Mvc_Collection, delete){ PHALCON_INIT_VAR(options); array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); /** * Remove the instance From 7c16f551fec70b80b31431471549fa4b3b859c75 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Mon, 13 Jan 2014 04:22:49 +0200 Subject: [PATCH 3/6] Regenerated build/ --- build/32bits/phalcon.c | 4 ++-- build/64bits/phalcon.c | 4 ++-- build/safe/phalcon.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/32bits/phalcon.c b/build/32bits/phalcon.c index a6e21c66faa..184a2e89060 100644 --- a/build/32bits/phalcon.c +++ b/build/32bits/phalcon.c @@ -79998,7 +79998,7 @@ static PHP_METHOD(Phalcon_Mvc_Collection, save){ MAKE_STD_ZVAL(options); Z_SET_REFCOUNT_P(options, 0); /* will be automatically destroyed by Zend on return from method call */ array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p2_key(status, collection, "save", data, options, 274150868UL); @@ -80400,7 +80400,7 @@ static PHP_METHOD(Phalcon_Mvc_Collection, delete){ PHALCON_INIT_VAR(options); array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p2_key(status, collection, "remove", id_condition, options, 1052443347UL); diff --git a/build/64bits/phalcon.c b/build/64bits/phalcon.c index ff9e44eec38..1da160153ca 100644 --- a/build/64bits/phalcon.c +++ b/build/64bits/phalcon.c @@ -79998,7 +79998,7 @@ static PHP_METHOD(Phalcon_Mvc_Collection, save){ MAKE_STD_ZVAL(options); Z_SET_REFCOUNT_P(options, 0); /* will be automatically destroyed by Zend on return from method call */ array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p2_key(status, collection, "save", data, options, 210727548372UL); @@ -80400,7 +80400,7 @@ static PHP_METHOD(Phalcon_Mvc_Collection, delete){ PHALCON_INIT_VAR(options); array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p2_key(status, collection, "remove", id_condition, options, 229481155068627UL); diff --git a/build/safe/phalcon.c b/build/safe/phalcon.c index 4857a5fab07..bcc1ae4f1b6 100644 --- a/build/safe/phalcon.c +++ b/build/safe/phalcon.c @@ -79998,7 +79998,7 @@ static PHP_METHOD(Phalcon_Mvc_Collection, save){ MAKE_STD_ZVAL(options); Z_SET_REFCOUNT_P(options, 0); /* will be automatically destroyed by Zend on return from method call */ array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p2(status, collection, "save", data, options); @@ -80400,7 +80400,7 @@ static PHP_METHOD(Phalcon_Mvc_Collection, delete){ PHALCON_INIT_VAR(options); array_init_size(options, 1); - add_assoc_bool_ex(options, SS("safe"), 1); + add_assoc_long_ex(options, SS("w"), 1); PHALCON_INIT_NVAR(status); phalcon_call_method_p2(status, collection, "remove", id_condition, options); From 683b3996e1b504b42c985c26c878f1562705be9f Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Mon, 13 Jan 2014 14:16:56 +0200 Subject: [PATCH 4/6] Fix #1681 --- ext/kernel/filter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/kernel/filter.c b/ext/kernel/filter.c index 8b8cd359c4b..b7112be3d8f 100644 --- a/ext/kernel/filter.c +++ b/ext/kernel/filter.c @@ -170,7 +170,7 @@ static long phalcon_unpack(char *data, int size, int issigned, int *map) static inline char *phalcon_longtohex(unsigned long value) { static char digits[] = "0123456789abcdef"; - char buf[(sizeof(unsigned long) << 3) + 1]; + char buf[(sizeof(unsigned long) << 1) + 1]; char *ptr, *end; end = ptr = buf + sizeof(buf) - 1; @@ -257,7 +257,7 @@ void phalcon_escape_multi(zval *return_value, zval *param, const char *escape_ch /** * Alphanumeric characters are not escaped */ - if (value < 256 && isalnum(value)) { + if (value > 32 && value < 127 && isalnum(value)) { smart_str_appendc(&escaped_str, (unsigned char) value); continue; } @@ -292,6 +292,8 @@ void phalcon_escape_multi(zval *return_value, zval *param, const char *escape_ch case ';': case '_': case '|': + case '~': + case '`': smart_str_appendc(&escaped_str, (unsigned char) value); continue; } From 1c7d275cb17f7b90f4a3c8f2f2a9f7aa79f6e462 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Mon, 13 Jan 2014 14:18:13 +0200 Subject: [PATCH 5/6] Updated CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 2c510d72b31..7b3eb9a8529 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ - Fixed PHP Notices in Phalcon\Debug::onUncaughtException() (#1683) - Phalcon\Logger\Adapter::commit() clears the queue (#1748) - Constant-time string comparison in Phalcon\Security::checkHash() (#1755) + - Fix phalcon_escape_multi() to generate valid UTF-8 (#1681) 1.2.4 - Fixed broken ACL inheritance (#905) From 8ff66b837d2463b1fbdbe4e96aee69ced51f7dd0 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Mon, 13 Jan 2014 14:18:53 +0200 Subject: [PATCH 6/6] Regenerated build/ --- build/32bits/phalcon.c | 6 ++++-- build/64bits/phalcon.c | 6 ++++-- build/safe/phalcon.c | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build/32bits/phalcon.c b/build/32bits/phalcon.c index 184a2e89060..9421c5e5c1c 100644 --- a/build/32bits/phalcon.c +++ b/build/32bits/phalcon.c @@ -7481,7 +7481,7 @@ static long phalcon_unpack(char *data, int size, int issigned, int *map) static inline char *phalcon_longtohex(unsigned long value) { static char digits[] = "0123456789abcdef"; - char buf[(sizeof(unsigned long) << 3) + 1]; + char buf[(sizeof(unsigned long) << 1) + 1]; char *ptr, *end; end = ptr = buf + sizeof(buf) - 1; @@ -7552,7 +7552,7 @@ static void phalcon_escape_multi(zval *return_value, zval *param, const char *es RETURN_FALSE; } - if (value < 256 && isalnum(value)) { + if (value > 32 && value < 127 && isalnum(value)) { smart_str_appendc(&escaped_str, (unsigned char) value); continue; } @@ -7584,6 +7584,8 @@ static void phalcon_escape_multi(zval *return_value, zval *param, const char *es case ';': case '_': case '|': + case '~': + case '`': smart_str_appendc(&escaped_str, (unsigned char) value); continue; } diff --git a/build/64bits/phalcon.c b/build/64bits/phalcon.c index 1da160153ca..1ad84eb91da 100644 --- a/build/64bits/phalcon.c +++ b/build/64bits/phalcon.c @@ -7481,7 +7481,7 @@ static long phalcon_unpack(char *data, int size, int issigned, int *map) static inline char *phalcon_longtohex(unsigned long value) { static char digits[] = "0123456789abcdef"; - char buf[(sizeof(unsigned long) << 3) + 1]; + char buf[(sizeof(unsigned long) << 1) + 1]; char *ptr, *end; end = ptr = buf + sizeof(buf) - 1; @@ -7552,7 +7552,7 @@ static void phalcon_escape_multi(zval *return_value, zval *param, const char *es RETURN_FALSE; } - if (value < 256 && isalnum(value)) { + if (value > 32 && value < 127 && isalnum(value)) { smart_str_appendc(&escaped_str, (unsigned char) value); continue; } @@ -7584,6 +7584,8 @@ static void phalcon_escape_multi(zval *return_value, zval *param, const char *es case ';': case '_': case '|': + case '~': + case '`': smart_str_appendc(&escaped_str, (unsigned char) value); continue; } diff --git a/build/safe/phalcon.c b/build/safe/phalcon.c index bcc1ae4f1b6..547fe961d52 100644 --- a/build/safe/phalcon.c +++ b/build/safe/phalcon.c @@ -7481,7 +7481,7 @@ static long phalcon_unpack(char *data, int size, int issigned, int *map) static inline char *phalcon_longtohex(unsigned long value) { static char digits[] = "0123456789abcdef"; - char buf[(sizeof(unsigned long) << 3) + 1]; + char buf[(sizeof(unsigned long) << 1) + 1]; char *ptr, *end; end = ptr = buf + sizeof(buf) - 1; @@ -7552,7 +7552,7 @@ static void phalcon_escape_multi(zval *return_value, zval *param, const char *es RETURN_FALSE; } - if (value < 256 && isalnum(value)) { + if (value > 32 && value < 127 && isalnum(value)) { smart_str_appendc(&escaped_str, (unsigned char) value); continue; } @@ -7584,6 +7584,8 @@ static void phalcon_escape_multi(zval *return_value, zval *param, const char *es case ';': case '_': case '|': + case '~': + case '`': smart_str_appendc(&escaped_str, (unsigned char) value); continue; }