Fossil SCM

Additional efforts to limit depth of recursion in markdown.

drh 2019-09-24 18:16 trunk
Commit cd5e9f265de1a0d57fcdab55ee2a8c96823e11eb20142d67164fdc9ed7810581
1 file changed +9 -1
+9 -1
--- src/markdown.c
+++ src/markdown.c
@@ -432,10 +432,14 @@
432432
){
433433
size_t i = 0, end = 0;
434434
char_trigger action = 0;
435435
struct Blob work = BLOB_INITIALIZER;
436436
437
+ if( too_deep(rndr) ){
438
+ blob_append(ob, data, size);
439
+ return;
440
+ }
437441
while( i<size ){
438442
/* copying inactive chars into the output */
439443
while( end<size
440444
&& (action = rndr->active_char[(unsigned char)data[end]])==0
441445
){
@@ -1305,11 +1309,15 @@
13051309
}
13061310
beg = end;
13071311
}
13081312
13091313
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
+ }
13111319
rndr->make.blockquote(ob, out, rndr->make.opaque);
13121320
}
13131321
release_work_buffer(rndr, out);
13141322
return end;
13151323
}
13161324
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button