summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-08-23 20:57:49 +0200
committerBoris Faure <billiob@gmail.com>2015-08-23 20:57:49 +0200
commit144e0b5068aa25b7fce822a94101586f374aa236 (patch)
tree1fe8fabc2a57990461a3ad544704b57095ef6357 /src
parent5c9d98cf22cf728f0f7dd759efc5c2f7e15460ce (diff)
add option to disable terminology escape codes that could be considered
security issues by some They are enabled by default.
Diffstat (limited to 'src')
-rw-r--r--src/bin/config.c13
-rw-r--r--src/bin/config.h1
-rw-r--r--src/bin/options_behavior.c2
-rw-r--r--src/bin/termio.c128
-rw-r--r--src/bin/termptyesc.c17
5 files changed, 117 insertions, 44 deletions
diff --git a/src/bin/config.c b/src/bin/config.c
index ee0588a..69f5abc 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -7,7 +7,7 @@
7#include "col.h" 7#include "col.h"
8#include "utils.h" 8#include "utils.h"
9 9
10#define CONF_VER 5 10#define CONF_VER 6
11 11
12#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;} 12#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
13 13
@@ -163,6 +163,8 @@ config_init(void)
163 (edd_base, Config, "notabs", notabs, EET_T_UCHAR); 163 (edd_base, Config, "notabs", notabs, EET_T_UCHAR);
164 EET_DATA_DESCRIPTOR_ADD_BASIC 164 EET_DATA_DESCRIPTOR_ADD_BASIC
165 (edd_base, Config, "mv_always_show", mv_always_show, EET_T_UCHAR); 165 (edd_base, Config, "mv_always_show", mv_always_show, EET_T_UCHAR);
166 EET_DATA_DESCRIPTOR_ADD_BASIC
167 (edd_base, Config, "ty_escapes", ty_escapes, EET_T_UCHAR);
166} 168}
167 169
168void 170void
@@ -261,6 +263,8 @@ config_sync(const Config *config_src, Config *config)
261 /* TODO: config->keys */ 263 /* TODO: config->keys */
262 config->gravatar = config_src->gravatar; 264 config->gravatar = config_src->gravatar;
263 config->notabs = config_src->notabs; 265 config->notabs = config_src->notabs;
266 config->mv_always_show = config_src->mv_always_show;
267 config->ty_escapes = config_src->ty_escapes;
264} 268}
265 269
266static void 270static void
@@ -472,7 +476,10 @@ config_load(const char *key)
472 case 4: 476 case 4:
473 config->version = 5; 477 config->version = 5;
474 /*pass through*/ 478 /*pass through*/
475 case CONF_VER: /* 5 */ 479 case 5:
480 config->ty_escapes = EINA_TRUE;
481 /*pass through*/
482 case CONF_VER: /* 6 */
476 config->version = CONF_VER; 483 config->version = CONF_VER;
477 break; 484 break;
478 default: 485 default:
@@ -536,6 +543,7 @@ config_load(const char *key)
536 config->gravatar = EINA_TRUE; 543 config->gravatar = EINA_TRUE;
537 config->notabs = EINA_FALSE; 544 config->notabs = EINA_FALSE;
538 config->mv_always_show = EINA_FALSE; 545 config->mv_always_show = EINA_FALSE;
546 config->ty_escapes = EINA_TRUE;
539 for (j = 0; j < 4; j++) 547 for (j = 0; j < 4; j++)
540 { 548 {
541 for (i = 0; i < 12; i++) 549 for (i = 0; i < 12; i++)
@@ -628,6 +636,7 @@ config_fork(Config *config)
628 CPY(gravatar); 636 CPY(gravatar);
629 CPY(notabs); 637 CPY(notabs);
630 CPY(mv_always_show); 638 CPY(mv_always_show);
639 CPY(ty_escapes);
631 640
632 EINA_LIST_FOREACH(config->keys, l, key) 641 EINA_LIST_FOREACH(config->keys, l, key)
633 { 642 {
diff --git a/src/bin/config.h b/src/bin/config.h
index c7d3a10..7923669 100644
--- a/src/bin/config.h
+++ b/src/bin/config.h
@@ -75,6 +75,7 @@ struct _Config
75 Eina_Bool gravatar; 75 Eina_Bool gravatar;
76 Eina_Bool notabs; 76 Eina_Bool notabs;
77 Eina_Bool mv_always_show; 77 Eina_Bool mv_always_show;
78 Eina_Bool ty_escapes;
78 Config_Color colors[(4 * 12)]; 79 Config_Color colors[(4 * 12)];
79 Eina_List *keys; 80 Eina_List *keys;
80 81
diff --git a/src/bin/options_behavior.c b/src/bin/options_behavior.c
index 95bf634..d889a46 100644
--- a/src/bin/options_behavior.c
+++ b/src/bin/options_behavior.c
@@ -42,6 +42,7 @@ CB(mouse_over_focus, 0);
42CB(gravatar, 0); 42CB(gravatar, 0);
43CB(notabs, 1); 43CB(notabs, 1);
44CB(mv_always_show, 0); 44CB(mv_always_show, 0);
45CB(ty_escapes, 0);
45 46
46#undef CB 47#undef CB
47 48
@@ -191,6 +192,7 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
191 CX(_("Gravatar integration"), gravatar, 0); 192 CX(_("Gravatar integration"), gravatar, 0);
192 CX(_("Show tabs"), notabs, 1); 193 CX(_("Show tabs"), notabs, 1);
193 CX(_("Always show miniview"), mv_always_show, 0); 194 CX(_("Always show miniview"), mv_always_show, 0);
195 CX(_("Enable special Terminology escape codes"), ty_escapes, 0);
194 196
195#undef CX 197#undef CX
196 198
diff --git a/src/bin/termio.c b/src/bin/termio.c
index b879432..6eb1c8d 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -5463,16 +5463,72 @@ _smart_pty_command(void *data)
5463{ 5463{
5464 Evas_Object *obj = data; 5464 Evas_Object *obj = data;
5465 Termio *sd = evas_object_smart_data_get(obj); 5465 Termio *sd = evas_object_smart_data_get(obj);
5466 Config *config;
5467 Termpty *ty;
5466 5468
5467 EINA_SAFETY_ON_NULL_RETURN(sd); 5469 EINA_SAFETY_ON_NULL_RETURN(sd);
5468 if (!sd->pty->cur_cmd) return; 5470
5469 if (sd->pty->cur_cmd[0] == 'i') 5471 config = sd->config;
5470 { 5472 ty = sd->pty;
5471 if ((sd->pty->cur_cmd[1] == 's') || 5473 if (!ty->cur_cmd)
5472 (sd->pty->cur_cmd[1] == 'c') || 5474 return;
5473 (sd->pty->cur_cmd[1] == 'f') || 5475 if (ty->cur_cmd[0] == 'q')
5474 (sd->pty->cur_cmd[1] == 't') || 5476 {
5475 (sd->pty->cur_cmd[1] == 'j')) 5477 if (ty->cur_cmd[1] == 's')
5478 {
5479 char buf[256];
5480
5481 snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n",
5482 sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh);
5483 termpty_write(ty, buf, strlen(buf));
5484 return;
5485 }
5486 else if (ty->cur_cmd[1] == 'j')
5487 {
5488 const char *chid = &(ty->cur_cmd[3]);
5489
5490 if (ty->cur_cmd[2])
5491 {
5492 if (ty->cur_cmd[2] == '+')
5493 {
5494 sd->cur_chids = eina_list_append
5495 (sd->cur_chids, eina_stringshare_add(chid));
5496 }
5497 else if (ty->cur_cmd[2] == '-')
5498 {
5499 Eina_List *l;
5500 char *chid2;
5501
5502 EINA_LIST_FOREACH(sd->cur_chids, l, chid2)
5503 {
5504 if (!(!strcmp(chid, chid2)))
5505 {
5506 sd->cur_chids =
5507 eina_list_remove_list(sd->cur_chids, l);
5508 eina_stringshare_del(chid2);
5509 break;
5510 }
5511 }
5512 }
5513 }
5514 else
5515 {
5516 EINA_LIST_FREE(sd->cur_chids, chid)
5517 eina_stringshare_del(chid);
5518 }
5519 return;
5520 }
5521 return;
5522 }
5523 if (!config->ty_escapes)
5524 return;
5525 if (ty->cur_cmd[0] == 'i')
5526 {
5527 if ((ty->cur_cmd[1] == 's') ||
5528 (ty->cur_cmd[1] == 'c') ||
5529 (ty->cur_cmd[1] == 'f') ||
5530 (ty->cur_cmd[1] == 't') ||
5531 (ty->cur_cmd[1] == 'j'))
5476 { 5532 {
5477 const char *p, *p0, *p1, *path = NULL; 5533 const char *p, *p0, *p1, *path = NULL;
5478 char *pp; 5534 char *pp;
@@ -5491,12 +5547,12 @@ _smart_pty_command(void *data)
5491 // \nCMD\nP1[\nP2][\nP3][[\nCMD2\nP21[\nP22]]... 5547 // \nCMD\nP1[\nP2][\nP3][[\nCMD2\nP21[\nP22]]...
5492 // CMD is the command, P1, P2, P3 etc. are parameters (P2 and 5548 // CMD is the command, P1, P2, P3 etc. are parameters (P2 and
5493 // on are optional depending on CMD) 5549 // on are optional depending on CMD)
5494 repch = sd->pty->cur_cmd[2]; 5550 repch = ty->cur_cmd[2];
5495 if (repch) 5551 if (repch)
5496 { 5552 {
5497 char *link = NULL; 5553 char *link = NULL;
5498 5554
5499 for (p0 = p = &(sd->pty->cur_cmd[3]); *p; p++) 5555 for (p0 = p = &(ty->cur_cmd[3]); *p; p++)
5500 { 5556 {
5501 if (*p == ';') 5557 if (*p == ';')
5502 { 5558 {
@@ -5514,7 +5570,7 @@ _smart_pty_command(void *data)
5514 break; 5570 break;
5515 } 5571 }
5516 } 5572 }
5517 if (sd->pty->cur_cmd[1] == 'j') 5573 if (ty->cur_cmd[1] == 'j')
5518 { 5574 {
5519 // parse from p until end of string - one newline 5575 // parse from p until end of string - one newline
5520 // per list item in strs 5576 // per list item in strs
@@ -5572,7 +5628,7 @@ _smart_pty_command(void *data)
5572 file = eina_list_nth(strs, 0); 5628 file = eina_list_nth(strs, 0);
5573 group = eina_list_nth(strs, 1); 5629 group = eina_list_nth(strs, 1);
5574 l = eina_list_nth_list(strs, 2); 5630 l = eina_list_nth_list(strs, 2);
5575 blk = termpty_block_new(sd->pty, ww, hh, file, group); 5631 blk = termpty_block_new(ty, ww, hh, file, group);
5576 for (;l; l = l->next) 5632 for (;l; l = l->next)
5577 { 5633 {
5578 pp = l->data; 5634 pp = l->data;
@@ -5582,20 +5638,20 @@ _smart_pty_command(void *data)
5582 } 5638 }
5583 } 5639 }
5584 else 5640 else
5585 blk = termpty_block_new(sd->pty, ww, hh, path, link); 5641 blk = termpty_block_new(ty, ww, hh, path, link);
5586 if (blk) 5642 if (blk)
5587 { 5643 {
5588 if (sd->pty->cur_cmd[1] == 's') 5644 if (ty->cur_cmd[1] == 's')
5589 blk->scale_stretch = EINA_TRUE; 5645 blk->scale_stretch = EINA_TRUE;
5590 else if (sd->pty->cur_cmd[1] == 'c') 5646 else if (ty->cur_cmd[1] == 'c')
5591 blk->scale_center = EINA_TRUE; 5647 blk->scale_center = EINA_TRUE;
5592 else if (sd->pty->cur_cmd[1] == 'f') 5648 else if (ty->cur_cmd[1] == 'f')
5593 blk->scale_fill = EINA_TRUE; 5649 blk->scale_fill = EINA_TRUE;
5594 else if (sd->pty->cur_cmd[1] == 't') 5650 else if (ty->cur_cmd[1] == 't')
5595 blk->thumb = EINA_TRUE; 5651 blk->thumb = EINA_TRUE;
5596 else if (sd->pty->cur_cmd[1] == 'j') 5652 else if (ty->cur_cmd[1] == 'j')
5597 blk->edje = EINA_TRUE; 5653 blk->edje = EINA_TRUE;
5598 termpty_block_insert(sd->pty, repch, blk); 5654 termpty_block_insert(ty, repch, blk);
5599 } 5655 }
5600 } 5656 }
5601 free(link); 5657 free(link);
@@ -5603,14 +5659,14 @@ _smart_pty_command(void *data)
5603 } 5659 }
5604 return; 5660 return;
5605 } 5661 }
5606 else if (sd->pty->cur_cmd[1] == 'C') 5662 else if (ty->cur_cmd[1] == 'C')
5607 { 5663 {
5608 Termblock *blk = NULL; 5664 Termblock *blk = NULL;
5609 const char *p, *p0, *p1; 5665 const char *p, *p0, *p1;
5610 char *pp; 5666 char *pp;
5611 Eina_List *strs = NULL; 5667 Eina_List *strs = NULL;
5612 5668
5613 p = &(sd->pty->cur_cmd[2]); 5669 p = &(ty->cur_cmd[2]);
5614 // parse from p until end of string - one newline 5670 // parse from p until end of string - one newline
5615 // per list item in strs 5671 // per list item in strs
5616 p0 = p1 = p; 5672 p0 = p1 = p;
@@ -5642,46 +5698,46 @@ _smart_pty_command(void *data)
5642 if (strs) 5698 if (strs)
5643 { 5699 {
5644 char *chid = strs->data; 5700 char *chid = strs->data;
5645 blk = termpty_block_chid_get(sd->pty, chid); 5701 blk = termpty_block_chid_get(ty, chid);
5646 if (blk) 5702 if (blk)
5647 { 5703 {
5648 _block_edje_cmds(sd->pty, blk, strs->next, EINA_FALSE); 5704 _block_edje_cmds(ty, blk, strs->next, EINA_FALSE);
5649 } 5705 }
5650 } 5706 }
5651 EINA_LIST_FREE(strs, pp) free(pp); 5707 EINA_LIST_FREE(strs, pp) free(pp);
5652 } 5708 }
5653 else if (sd->pty->cur_cmd[1] == 'b') 5709 else if (ty->cur_cmd[1] == 'b')
5654 { 5710 {
5655 sd->pty->block.on = EINA_TRUE; 5711 ty->block.on = EINA_TRUE;
5656 } 5712 }
5657 else if (sd->pty->cur_cmd[1] == 'e') 5713 else if (ty->cur_cmd[1] == 'e')
5658 { 5714 {
5659 sd->pty->block.on = EINA_FALSE; 5715 ty->block.on = EINA_FALSE;
5660 } 5716 }
5661 } 5717 }
5662 else if (sd->pty->cur_cmd[0] == 'q') 5718 else if (ty->cur_cmd[0] == 'q')
5663 { 5719 {
5664 if (sd->pty->cur_cmd[1] == 's') 5720 if (ty->cur_cmd[1] == 's')
5665 { 5721 {
5666 char buf[256]; 5722 char buf[256];
5667 5723
5668 snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n", 5724 snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n",
5669 sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh); 5725 sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh);
5670 termpty_write(sd->pty, buf, strlen(buf)); 5726 termpty_write(ty, buf, strlen(buf));
5671 return; 5727 return;
5672 } 5728 }
5673 else if (sd->pty->cur_cmd[1] == 'j') 5729 else if (ty->cur_cmd[1] == 'j')
5674 { 5730 {
5675 const char *chid = &(sd->pty->cur_cmd[3]); 5731 const char *chid = &(ty->cur_cmd[3]);
5676 5732
5677 if (sd->pty->cur_cmd[2]) 5733 if (ty->cur_cmd[2])
5678 { 5734 {
5679 if (sd->pty->cur_cmd[2] == '+') 5735 if (ty->cur_cmd[2] == '+')
5680 { 5736 {
5681 sd->cur_chids = eina_list_append 5737 sd->cur_chids = eina_list_append
5682 (sd->cur_chids, eina_stringshare_add(chid)); 5738 (sd->cur_chids, eina_stringshare_add(chid));
5683 } 5739 }
5684 else if (sd->pty->cur_cmd[2] == '-') 5740 else if (ty->cur_cmd[2] == '-')
5685 { 5741 {
5686 Eina_List *l; 5742 Eina_List *l;
5687 char *chid2; 5743 char *chid2;
@@ -5706,7 +5762,7 @@ _smart_pty_command(void *data)
5706 return; 5762 return;
5707 } 5763 }
5708 } 5764 }
5709 evas_object_smart_callback_call(obj, "command", (void *)sd->pty->cur_cmd); 5765 evas_object_smart_callback_call(obj, "command", (void *)ty->cur_cmd);
5710} 5766}
5711 5767
5712#if !((ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8)) 5768#if !((ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8))
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index bd525c3..301574a 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1442,8 +1442,11 @@ _handle_esc_terminology(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *
1442{ 1442{
1443 Eina_Unicode *cc; 1443 Eina_Unicode *cc;
1444 Eina_Unicode *buf, bufsmall[1024], *b; 1444 Eina_Unicode *buf, bufsmall[1024], *b;
1445 char *s; 1445 char *cmd;
1446 int blen = 0, slen = 0; 1446 int blen = 0;
1447 Config *config;
1448
1449 config = termio_config_get(ty->obj);
1447 1450
1448 cc = (Eina_Unicode *)c; 1451 cc = (Eina_Unicode *)c;
1449 while ((cc < ce) && (*cc != 0x0)) 1452 while ((cc < ce) && (*cc != 0x0))
@@ -1469,15 +1472,17 @@ _handle_esc_terminology(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *
1469 return 0; 1472 return 0;
1470 } 1473 }
1471 *b = 0; 1474 *b = 0;
1475
1472 // commands are stored in the buffer, 0 bytes not allowed (end marker) 1476 // commands are stored in the buffer, 0 bytes not allowed (end marker)
1473 s = eina_unicode_unicode_to_utf8(buf, &slen); 1477 cmd = eina_unicode_unicode_to_utf8(buf, NULL);
1474 ty->cur_cmd = s; 1478 ty->cur_cmd = cmd;
1475 if (!_termpty_ext_handle(ty, s, buf)) 1479 if ((!config->ty_escapes) || (!_termpty_ext_handle(ty, cmd, buf)))
1476 { 1480 {
1477 if (ty->cb.command.func) ty->cb.command.func(ty->cb.command.data); 1481 if (ty->cb.command.func) ty->cb.command.func(ty->cb.command.data);
1478 } 1482 }
1479 ty->cur_cmd = NULL; 1483 ty->cur_cmd = NULL;
1480 free(s); 1484 free(cmd);
1485
1481 if (buf != bufsmall) free(buf); 1486 if (buf != bufsmall) free(buf);
1482 return cc - c; 1487 return cc - c;
1483} 1488}