Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'development'

  • Loading branch information...
commit 5c3190c51d8fe588b138ba9f4fd465dff46c0906 2 parents fbd4274 + 8bbfea0
@chobie authored
View
50 package.xml
@@ -15,9 +15,9 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz
<email>chobieeee@php.net</email>
<active>yes</active>
</lead>
- <date>2012-08-11</date>
+ <date>2012-09-30</date>
<version>
- <release>0.3.7</release>
+ <release>0.3.8</release>
<api>0.3.7</api>
</version>
<stability>
@@ -26,21 +26,11 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
- * 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
</notes>
<contents>
<dir name="/">
@@ -89,6 +79,7 @@ ebae34b Make travis report test failure since make test didn't report exit code
<file role="test" name="999-regression-no12.phpt" />
<file role="test" name="999-regression-no19.phpt" />
<file role="test" name="999-regression-no26.phpt" />
+ <file role="test" name="999-regression-no28.phpt" />
</dir>
<dir name="docs">
<file role="doc" name="ExtensionsAndRenderFlags.md" />
@@ -139,6 +130,35 @@ ebae34b Make travis report test failure since make test didn't report exit code
<api>beta</api>
</stability>
<version>
+ <release>0.3.7</release>
+ <api>0.3.7</api>
+ </version>
+ <date>2012-08-11</date>
+ <notes>
+ * 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
+</notes>
+ </release>
+
+ <release>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <version>
<release>0.3.6</release>
<api>0.3.6</api>
</version>
View
15 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 */
View
41 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")) {
2  sundown
@@ -1 +1 @@
-Subproject commit 8e5b0d14c9021981dbad364c6860c2ab18a40666
+Subproject commit b6b58da3ffd43bc730174b49f0bb0a5ca3d969a5
View
16 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(&params[0]);
zval_dtor(&postprocess);
- zval_dtor(&preprocess);
zval_ptr_dtor(&render);
}
/* }}} */
View
32 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--
+<?php if (!extension_loaded("sundown")) print "skip"; ?>
+--FILE--
+<?php
+class R extends \Sundown\Render\Base
+{
+ public function image($link, $title, $alt)
+ {
+ if ($link == 'doesnt/exists.jpg') {
+ throw new \Exception("err");
+ }
+ }
+}
+
+$c = <<<EOM
+# Doc
+
+![](doesnt/exists.jpg)
+
+![](https://www.google.com/images/srpr/logo3w.png)
+EOM;
+
+$m = new \Sundown\Markdown(new R(), array('autolink' => true));
+try {
+ $m->render($c);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+--EXPECT--
+err
Please sign in to comment.
Something went wrong with that request. Please try again.