Bug 344977 - Escape sequence causes konsole to reset to profile defaults
Summary: Escape sequence causes konsole to reset to profile defaults
Status: RESOLVED DUPLICATE of bug 323227
Alias: None
Product: konsole
Classification: Applications
Component: emulation (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-09 14:52 UTC by Marc Paradise
Modified: 2018-03-05 14:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Paradise 2015-03-09 14:52:03 UTC
The following escape sequence will cause Konsole to reset to current profile defaults: 

printf '\033]50;anything\007\033\\'

This escape sequence is commonly used in vim to change cursor shape (in that case replace 'anything' with CursorShape=1 or CursorShape=0)

I think I've been able to track this one down. 

This is likely related to #323227 

TLDR: 

Here we see UserTitleChange::ProfileCHange enum value of 50: 
https://projects.kde.org/projects/kde/applications/konsole/repository/revisions/master/entry/src/Session.h#L358

I am not set up to build or test Konsole, or I'd submit a patch for this, but I *think* that finding a safe(?) value for ProfileChange attribute -  perhaps something > 255 since an escape sequence should never triggers this -  will resolve it. 

More details: 

In Vt102Emulation.cpp, first: 
https://projects.kde.org/projects/kde/applications/konsole/repository/revisions/master/entry/src/Vt102Emulation.cpp#L282 : 

#define Xpe  (tokenBufferPos >= 2 && tokenBuffer[1] == ']') // evals true in this case 
#define Xte (Xpe && cc = 7)  // evals true in this case 

And then in receiveChar:

 https://projects.kde.org/projects/kde/applications/konsole/repository/revisions/master/entry/src/Vt102Emulation.cpp#L321

// Xte evals true in this case 
if (Xte         ) { processWindowAttributeChange(); resetTokenizer(); return; }

processWindowAttributeChange looks at the token buffer which is: 
//  '\033]50;anything\007\033\\'

[0] = ESC
[1] = ']'
[2] = '5' 
[3] = '0' 
[4] = ';'

Assigns attributeToChange = 50

This then gets emitted in a titleUpdate - and the changed attribute now corresponds to the ProfileChange attribute.  Session sees that it changed and does what it thinks is correct - calls for a reset of the profile.
Comment 1 Ahmad Samir 2018-03-05 14:40:07 UTC
IINM, this is the same as bug 323227, using an escape sequence to change a profile property doesn't reset the profile settings but actually creates a new temporary profile (that's actually a copy of the current profile), and that temporary profile has an empty name.

*** This bug has been marked as a duplicate of bug 323227 ***