Fossil SCM
Extend test-chat-formatter to be able to render both wiki and markdown.
Commit
09ee2c8e718a8a05e767442841c0feffce621511d6a374c71ff5931b6c928de8
Parent
1d64640ec753387…
1 file changed
+9
-4
+9
-4
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -506,25 +506,30 @@ | ||
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /* |
| 509 | 509 | ** COMMAND: test-chat-formatter |
| 510 | 510 | ** |
| 511 | -** Usage: %fossil test-chat-formatter STRING ... | |
| 511 | +** Usage: %fossil test-chat-formatter ?OPTIONS? STRING ... | |
| 512 | 512 | ** |
| 513 | 513 | ** Transform each argument string into HTML that will display the |
| 514 | 514 | ** chat message. This is used to test the formatter and to verify |
| 515 | 515 | ** that a malicious message text will not cause HTML or JS injection |
| 516 | 516 | ** into the chat display in a browser. |
| 517 | +** | |
| 518 | +** Options: | |
| 519 | +** | |
| 520 | +** -w|--wiki Assume fossil wiki format instead of markdown | |
| 517 | 521 | */ |
| 518 | 522 | void chat_test_formatter_cmd(void){ |
| 519 | 523 | int i; |
| 520 | 524 | char *zOut; |
| 525 | + int const isWiki = find_option("w","wiki",0)!=0; | |
| 521 | 526 | db_find_and_open_repository(0,0); |
| 522 | 527 | g.perm.Hyperlink = 1; |
| 523 | - for(i=0; i<g.argc; i++){ | |
| 524 | - zOut = chat_format_to_html(g.argv[i], 0); | |
| 525 | - fossil_print("[%d]: %s\n", i, zOut); | |
| 528 | + for(i=2; i<g.argc; i++){ | |
| 529 | + zOut = chat_format_to_html(g.argv[i], isWiki); | |
| 530 | + fossil_print("[%d]: %s\n", i-1, zOut); | |
| 526 | 531 | fossil_free(zOut); |
| 527 | 532 | } |
| 528 | 533 | } |
| 529 | 534 | |
| 530 | 535 | /* |
| 531 | 536 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -506,25 +506,30 @@ | |
| 506 | } |
| 507 | |
| 508 | /* |
| 509 | ** COMMAND: test-chat-formatter |
| 510 | ** |
| 511 | ** Usage: %fossil test-chat-formatter STRING ... |
| 512 | ** |
| 513 | ** Transform each argument string into HTML that will display the |
| 514 | ** chat message. This is used to test the formatter and to verify |
| 515 | ** that a malicious message text will not cause HTML or JS injection |
| 516 | ** into the chat display in a browser. |
| 517 | */ |
| 518 | void chat_test_formatter_cmd(void){ |
| 519 | int i; |
| 520 | char *zOut; |
| 521 | db_find_and_open_repository(0,0); |
| 522 | g.perm.Hyperlink = 1; |
| 523 | for(i=0; i<g.argc; i++){ |
| 524 | zOut = chat_format_to_html(g.argv[i], 0); |
| 525 | fossil_print("[%d]: %s\n", i, zOut); |
| 526 | fossil_free(zOut); |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | /* |
| 531 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -506,25 +506,30 @@ | |
| 506 | } |
| 507 | |
| 508 | /* |
| 509 | ** COMMAND: test-chat-formatter |
| 510 | ** |
| 511 | ** Usage: %fossil test-chat-formatter ?OPTIONS? STRING ... |
| 512 | ** |
| 513 | ** Transform each argument string into HTML that will display the |
| 514 | ** chat message. This is used to test the formatter and to verify |
| 515 | ** that a malicious message text will not cause HTML or JS injection |
| 516 | ** into the chat display in a browser. |
| 517 | ** |
| 518 | ** Options: |
| 519 | ** |
| 520 | ** -w|--wiki Assume fossil wiki format instead of markdown |
| 521 | */ |
| 522 | void chat_test_formatter_cmd(void){ |
| 523 | int i; |
| 524 | char *zOut; |
| 525 | int const isWiki = find_option("w","wiki",0)!=0; |
| 526 | db_find_and_open_repository(0,0); |
| 527 | g.perm.Hyperlink = 1; |
| 528 | for(i=2; i<g.argc; i++){ |
| 529 | zOut = chat_format_to_html(g.argv[i], isWiki); |
| 530 | fossil_print("[%d]: %s\n", i-1, zOut); |
| 531 | fossil_free(zOut); |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | /* |
| 536 |