Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't support kitty images with trailing comma in control data #6561

Open
jwodder opened this issue Jan 7, 2025 · 0 comments
Open

Doesn't support kitty images with trailing comma in control data #6561

jwodder opened this issue Jan 7, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jwodder
Copy link

jwodder commented Jan 7, 2025

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20250103-121535-8e9cf912

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

The kitty graphics protocol description provides the following shell script for displaying a PNG using kitty:

#!/bin/bash
transmit_png() {
    data=$(base64 "$1")
    data="${data//[[:space:]]}"
    builtin local pos=0
    builtin local chunk_size=4096
    while [ $pos -lt ${#data} ]; do
        builtin printf "\e_G"
        [ $pos = "0" ] && printf "a=T,f=100,"
        builtin local chunk="${data:$pos:$chunk_size}"
        pos=$(($pos+$chunk_size))
        [ $pos -lt ${#data} ] && builtin printf "m=1"
        [ ${#chunk} -gt 0 ] && builtin printf ";%s" "${chunk}"
        builtin printf "\e\\"
    done
}

transmit_png "$1"

Running this script on an arbitrary small PNG in wezterm fails to display anything. However, if I move the trailing comma like so:

--- png-as-kitty0.sh	2025-01-07 11:59:49
+++ png-as-kitty.sh	2025-01-07 11:56:39
@@ -6,10 +6,10 @@
     builtin local chunk_size=4096
     while [ $pos -lt ${#data} ]; do
         builtin printf "\e_G"
-        [ $pos = "0" ] && printf "a=T,f=100,"
+        [ $pos = "0" ] && printf "a=T,f=100"
         builtin local chunk="${data:$pos:$chunk_size}"
         pos=$(($pos+$chunk_size))
-        [ $pos -lt ${#data} ] && builtin printf "m=1"
+        [ $pos -lt ${#data} ] && builtin printf ",m=1"
         [ ${#chunk} -gt 0 ] && builtin printf ";%s" "${chunk}"
         builtin printf "\e\\"
     done

then the image shows up. Presumably, wezterm is being thrown off by the trailing comma that is present in the control data when the last chunk (without m=1) is emitted. Since the script came from the author of kitty, I assume that the trailing comma should be accepted and that wezterm is in error for not supporting it.

To Reproduce

No response

Configuration

no config

Expected Behavior

No response

Logs

No response

Anything else?

No response

@jwodder jwodder added the bug Something isn't working label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant