Fossil SCM
Additional efforts to limit depth of recursion in markdown.
Commit
cd5e9f265de1a0d57fcdab55ee2a8c96823e11eb20142d67164fdc9ed7810581
Parent
a5835cac3b63d2d…
1 file changed
+9
-1
+9
-1
| --- src/markdown.c | ||
| +++ src/markdown.c | ||
| @@ -432,10 +432,14 @@ | ||
| 432 | 432 | ){ |
| 433 | 433 | size_t i = 0, end = 0; |
| 434 | 434 | char_trigger action = 0; |
| 435 | 435 | struct Blob work = BLOB_INITIALIZER; |
| 436 | 436 | |
| 437 | + if( too_deep(rndr) ){ | |
| 438 | + blob_append(ob, data, size); | |
| 439 | + return; | |
| 440 | + } | |
| 437 | 441 | while( i<size ){ |
| 438 | 442 | /* copying inactive chars into the output */ |
| 439 | 443 | while( end<size |
| 440 | 444 | && (action = rndr->active_char[(unsigned char)data[end]])==0 |
| 441 | 445 | ){ |
| @@ -1305,11 +1309,15 @@ | ||
| 1305 | 1309 | } |
| 1306 | 1310 | beg = end; |
| 1307 | 1311 | } |
| 1308 | 1312 | |
| 1309 | 1313 | if( rndr->make.blockquote ){ |
| 1310 | - parse_block(out, rndr, work_data, work_size); | |
| 1314 | + if( !too_deep(rndr) ){ | |
| 1315 | + parse_block(out, rndr, work_data, work_size); | |
| 1316 | + }else{ | |
| 1317 | + blob_append(out, work_data, work_size); | |
| 1318 | + } | |
| 1311 | 1319 | rndr->make.blockquote(ob, out, rndr->make.opaque); |
| 1312 | 1320 | } |
| 1313 | 1321 | release_work_buffer(rndr, out); |
| 1314 | 1322 | return end; |
| 1315 | 1323 | } |
| 1316 | 1324 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -432,10 +432,14 @@ | |
| 432 | ){ |
| 433 | size_t i = 0, end = 0; |
| 434 | char_trigger action = 0; |
| 435 | struct Blob work = BLOB_INITIALIZER; |
| 436 | |
| 437 | while( i<size ){ |
| 438 | /* copying inactive chars into the output */ |
| 439 | while( end<size |
| 440 | && (action = rndr->active_char[(unsigned char)data[end]])==0 |
| 441 | ){ |
| @@ -1305,11 +1309,15 @@ | |
| 1305 | } |
| 1306 | beg = end; |
| 1307 | } |
| 1308 | |
| 1309 | if( rndr->make.blockquote ){ |
| 1310 | parse_block(out, rndr, work_data, work_size); |
| 1311 | rndr->make.blockquote(ob, out, rndr->make.opaque); |
| 1312 | } |
| 1313 | release_work_buffer(rndr, out); |
| 1314 | return end; |
| 1315 | } |
| 1316 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -432,10 +432,14 @@ | |
| 432 | ){ |
| 433 | size_t i = 0, end = 0; |
| 434 | char_trigger action = 0; |
| 435 | struct Blob work = BLOB_INITIALIZER; |
| 436 | |
| 437 | if( too_deep(rndr) ){ |
| 438 | blob_append(ob, data, size); |
| 439 | return; |
| 440 | } |
| 441 | while( i<size ){ |
| 442 | /* copying inactive chars into the output */ |
| 443 | while( end<size |
| 444 | && (action = rndr->active_char[(unsigned char)data[end]])==0 |
| 445 | ){ |
| @@ -1305,11 +1309,15 @@ | |
| 1309 | } |
| 1310 | beg = end; |
| 1311 | } |
| 1312 | |
| 1313 | if( rndr->make.blockquote ){ |
| 1314 | if( !too_deep(rndr) ){ |
| 1315 | parse_block(out, rndr, work_data, work_size); |
| 1316 | }else{ |
| 1317 | blob_append(out, work_data, work_size); |
| 1318 | } |
| 1319 | rndr->make.blockquote(ob, out, rndr->make.opaque); |
| 1320 | } |
| 1321 | release_work_buffer(rndr, out); |
| 1322 | return end; |
| 1323 | } |
| 1324 |