Skip to content

Incorrect CSI ASCII Value #13

@avose

Description

@avose

I think the code is using the wrong value for CSI.

The code lists it as 153, but the following documents list it as 155.

https://man7.org/linux/man-pages/man4/console_codes.4.html

CSI (0x9B)
              is equivalent to ESC [.

https://www.xfree86.org/current/ctlseqs.html

ESC [    |   Control Sequence Introducer ( CSI is 0x9b)

It probably doesn't come up much, because this is hardly ever used. Most of the time the terminal emulator will get "ESC [" and not CSI.

Also, the code treats CSI and ESC essentially the same (with perhaps a broken bounds check on CSI?). See below:

    def __OnCharESC(self, text, index):
        """
        Handler for escape character
        """        
        index += 1
        if index < len(text):
            index = self.__HandleEscSeq(text, index)
        
        return index
    
    def __OnCharCSI(self, text, index):
        """
        Handler for control sequence intruducer(CSI) character
        """        
        index += 1
        index = self.__HandleEscSeq(text, index)
        return index
    def __HandleEscSeq(self, text, index):
        """
        Tries to parse escape sequence from input and if its not complete then
        puts it in unparsedInput and process it when the ProcessInput called
        next time.
        """
        if text[index] == '[':

However, if I understand the docs correctly, CSI doesn't need to be followed by a '[' character, as it's equivalent to 'ESC['. However, the code currently expects to see a '['. It seems to be treating CSI just like ESC, and not like 'ESC['.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions