diff --git a/package.xml b/package.xml
index 8f38a82..8309329 100644
--- a/package.xml
+++ b/package.xml
@@ -15,9 +15,9 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz
chobieeee@php.net
yes
- 2012-08-11
+ 2012-09-30
- 0.3.7
+ 0.3.8
0.3.7
@@ -26,21 +26,11 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz
PHP
- * bumped up 0.3.7
+ * bumped up 0.3.8
-fixed SEGV when processing tableCell and prettify source codes.
+- fixes #28 Wired memory limit error with autolink set.
+Sundown\Render\Base callbacks are able to throw exceptions.
-9582b04 update contributors
-1f11ace update README
-497d0a4 add a space after comma.
-7bc4703 fix several compile warnings
-a11eb98 update CFLAGS for fix compile warnings
-9a86d00 fixes #26:prevent SEGV when calling Sundwon\Base\tableCell
-26b77d6 change submodule to vmg/sundown from tanoku/sundown
-ee8a132 Merge pull request #24 from reeze/patch-2
-0a08969 Fix build in php-src
-b0adcc7 Merge pull request #23 from reeze/patch-1
-ebae34b Make travis report test failure since make test didn't report exit code
@@ -89,6 +79,7 @@ ebae34b Make travis report test failure since make test didn't report exit code
+
@@ -133,6 +124,35 @@ ebae34b Make travis report test failure since make test didn't report exit code
sundown
+
+
+ beta
+ beta
+
+
+ 0.3.7
+ 0.3.7
+
+ 2012-08-11
+
+ * bumped up 0.3.7
+
+fixed SEGV when processing tableCell and prettify source codes.
+
+9582b04 update contributors
+1f11ace update README
+497d0a4 add a space after comma.
+7bc4703 fix several compile warnings
+a11eb98 update CFLAGS for fix compile warnings
+9a86d00 fixes #26:prevent SEGV when calling Sundwon\Base\tableCell
+26b77d6 change submodule to vmg/sundown from tanoku/sundown
+ee8a132 Merge pull request #24 from reeze/patch-2
+0a08969 Fix build in php-src
+b0adcc7 Merge pull request #23 from reeze/patch-1
+ebae34b Make travis report test failure since make test didn't report exit code
+
+
+
beta
diff --git a/php_sundown.c b/php_sundown.c
index e240cfd..a43b314 100644
--- a/php_sundown.c
+++ b/php_sundown.c
@@ -18,6 +18,8 @@
#include "php_sundown.h"
+ZEND_DECLARE_MODULE_GLOBALS(sundown)
+
#include "ext/standard/info.h"
extern void php_sundown_render_base_init(TSRMLS_D);
@@ -212,8 +214,12 @@ static zend_function_entry php_sundown_methods[] = {
};
/* }}} */
-
PHP_MINIT_FUNCTION(sundown) {
+
+#ifdef ZTS
+ ts_allocate_id(&sundown_globals_id, sizeof(zend_sundown_globals), NULL, NULL);
+#endif
+
php_sundown_init(TSRMLS_C);
php_sundown_render_base_init(TSRMLS_C);
php_sundown_render_html_init(TSRMLS_C);
@@ -225,6 +231,11 @@ PHP_MINIT_FUNCTION(sundown) {
return SUCCESS;
}
+PHP_MSHUTDOWN_FUNCTION(sundown) {
+ return SUCCESS;
+}
+
+
PHP_MINFO_FUNCTION(sundown)
{
@@ -242,7 +253,7 @@ zend_module_entry sundown_module_entry = {
"sundown",
NULL, /* Functions */
PHP_MINIT(sundown), /* MINIT */
- NULL, /* MSHUTDOWN */
+ PHP_MSHUTDOWN(sundown), /* MSHUTDOWN */
NULL, /* RINIT */
NULL, /* RSHUTDOWN */
PHP_MINFO(sundown), /* MINFO */
diff --git a/php_sundown.h b/php_sundown.h
index d7e6d62..44a7dde 100644
--- a/php_sundown.h
+++ b/php_sundown.h
@@ -26,6 +26,23 @@
extern zend_module_entry sundown_module_entry;
#define phpext_sundown_ptr &sundown_module_entry
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+ZEND_BEGIN_MODULE_GLOBALS(sundown)
+ JMP_BUF jump;
+ZEND_END_MODULE_GLOBALS(sundown)
+
+/* Macro to access request-wide global variables. */
+#ifdef ZTS
+#define SUNDOWN_G(v) TSRMG(sundown_globals_id, zend_sundown_globals *, v)
+#else
+#define SUNDOWN_G(v) (sundown_globals.v)
+#endif
+
+ZEND_EXTERN_MODULE_GLOBALS(sundown)
+
extern zend_class_entry *sundown_class_entry, *php_sundown_buffer_class_entry;
typedef enum
@@ -76,15 +93,16 @@ typedef struct{
#define SPAN_CALLBACK_EX(buffer, method_name, ...) {\
struct php_sundown_renderopt_ex *opt = (struct php_sundown_renderopt_ex*)opaque;\
zval func, *ret;\
-\
+ TSRMLS_FETCH();\
+ \
MAKE_STD_ZVAL(ret);\
ZVAL_STRING(&func, method_name, 1);\
- \
if(call_user_function_v(NULL, &opt->self, &func, ret, __VA_ARGS__) == FAILURE){\
- fprintf(stderr, "Can't call method %s\n", method_name);\
- return 0;\
+ zval_ptr_dtor(&ret);\
+ zval_dtor(&func);\
+ LONGJMP(SUNDOWN_G(jump), 1);\
}\
- if (ret != NULL) {\
+ if (ret != NULL) {\
bufput(buffer, Z_STRVAL_P(ret), Z_STRLEN_P(ret));\
}\
zval_ptr_dtor(&ret);\
@@ -95,13 +113,15 @@ typedef struct{
#define BLOCK_CALLBACK_EX(buffer, method_name, ...) {\
struct php_sundown_renderopt_ex *opt = (struct php_sundown_renderopt_ex*)opaque;\
+ TSRMLS_FETCH();\
zval func, *ret;\
\
MAKE_STD_ZVAL(ret);\
ZVAL_STRING(&func, method_name, 1);\
- \
if(call_user_function_v(NULL, &opt->self, &func, ret, __VA_ARGS__) == FAILURE){\
- fprintf(stderr, "Can't call method %s\n", method_name);\
+ zval_ptr_dtor(&ret);\
+ zval_dtor(&func);\
+ LONGJMP(SUNDOWN_G(jump), 1);\
}\
if (ret != NULL) {\
bufput(buffer, Z_STRVAL_P(ret), Z_STRLEN_P(ret));\
@@ -278,8 +298,13 @@ static void php_sundown__get_extensions(HashTable *table, unsigned int *enabled_
extensions |= MKDEXT_STRIKETHROUGH;
}
+ /* obsoleted? */
if (SUNDOWN_HAS_EXTENSION("lax_html_blocks")) {
- extensions |= MKDEXT_LAX_HTML_BLOCKS;
+ extensions |= MKDEXT_LAX_SPACING;
+ }
+
+ if (SUNDOWN_HAS_EXTENSION("lax_spacing")) {
+ extensions |= MKDEXT_LAX_SPACING;
}
if (SUNDOWN_HAS_EXTENSION("space_after_headers")) {
diff --git a/sundown b/sundown
index 8e5b0d1..b6b58da 160000
--- a/sundown
+++ b/sundown
@@ -1 +1 @@
-Subproject commit 8e5b0d14c9021981dbad364c6860c2ab18a40666
+Subproject commit b6b58da3ffd43bc730174b49f0bb0a5ca3d969a5
diff --git a/sundown_markdown.c b/sundown_markdown.c
index 3986497..2785b2f 100644
--- a/sundown_markdown.c
+++ b/sundown_markdown.c
@@ -470,10 +470,19 @@ PHP_METHOD(sundown_markdown, render)
/* proceess markdown */
markdown = sd_markdown_new(enabled_extensions, 16, &sundown_render, &opt);
- sd_markdown_render(output_buf, input_buf.data, input_buf.size, markdown);
- sd_markdown_free(markdown);
+ if (SETJMP(SUNDOWN_G(jump)) == 0) {
+ sd_markdown_render(output_buf, input_buf.data, input_buf.size, markdown);
+ zval_dtor(&preprocess);
+ zval_ptr_dtor(&ret);
+ sd_markdown_free(markdown);
+ } else {
+ zval_dtor(&preprocess);
+ zval_ptr_dtor(&ret);
+ zval_ptr_dtor(&render);
+ sd_markdown_free(markdown);
+ return;
+ }
- zval_ptr_dtor(&ret);
/* postprocess */
MAKE_STD_ZVAL(ret);
MAKE_STD_ZVAL(params[0]);
@@ -490,7 +499,6 @@ PHP_METHOD(sundown_markdown, render)
zval_ptr_dtor(&ret);
zval_ptr_dtor(¶ms[0]);
zval_dtor(&postprocess);
- zval_dtor(&preprocess);
zval_ptr_dtor(&render);
}
/* }}} */
diff --git a/tests/999-regression-no28.phpt b/tests/999-regression-no28.phpt
new file mode 100644
index 0000000..68cf503
--- /dev/null
+++ b/tests/999-regression-no28.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Check for https://github.com/chobie/php-sundown/issues/28 (Render should interrupt by exception)
+--SKIPIF--
+
+--FILE--
+ true));
+try {
+ $m->render($c);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+--EXPECT--
+err
\ No newline at end of file