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

[BUG] cursive exits immediately when asked to display a string with a null byte #780

Open
janstarke opened this issue May 23, 2024 · 5 comments
Labels

Comments

@janstarke
Copy link

Describe the bug

cursive programs exit immediately when asked to display a string with a null byte. No error message is shown, and there doesn't seem to be a panic

To Reproduce

MWE:
This program should display a TextView, but instead it exists without any complaint.

use cursive::{views::TextView, Cursive, CursiveExt};

fn main() {
    let mut app = Cursive::new();
    app.add_layer(TextView::new("Hello Nullbyte: \0"));
    app.add_global_callback('q', |a| a.quit());
    app.run();
}

Expected behavior
This program should display a TextView, or at least panic with an error message, so that users of cursive know that null bytes are not allowed

Screenshots
no screenshot available

Environment

  • Ubuntu Linux
  • Backend used: ncurses (the default one)
  • de_DE.UTF-8
  • 0.20.0

Additional context
I found this while fixing janstarke/regview#8

@janstarke janstarke added the bug label May 23, 2024
@correabuscar

This comment was marked as outdated.

@correabuscar

This comment was marked as outdated.

correabuscar added a commit to correabuscar/cursive that referenced this issue May 25, 2024
...before sending the &str to ncurses backend,
this is done for cursive's print_at() and print_at_rep() only!
otherwise, nothing would get printed, silently.

Why delete \0 instead of replace with eg. space?
this explains it best:
gyscos#778 (comment)

This also fixes warnings about unused Result.

Closes: gyscos#780
correabuscar added a commit to correabuscar/cursive that referenced this issue May 25, 2024
...before sending the &str to ncurses backend,
this is done for cursive's print_at() and print_at_rep() only!
otherwise, nothing would get printed, silently.

Why delete \0 instead of replace with eg. space?
this explains it best:
gyscos#778 (comment)

This also fixes warnings about unused Result.

Closes: gyscos#780
correabuscar added a commit to correabuscar/cursive that referenced this issue May 28, 2024
...before sending the &str to ncurses backend,
this is done for cursive's print_at() and print_at_rep() only!
otherwise, nothing would get printed, silently.

Why delete \0 instead of replace with eg. space?
this explains it best:
gyscos#778 (comment)

This also fixes warnings about unused Result.

Closes: gyscos#780
correabuscar added a commit to correabuscar/cursive that referenced this issue May 30, 2024
...before sending the &str to ncurses backend,
this is done for cursive's print_at() and print_at_rep() only!
otherwise, nothing would get printed, silently.

Why delete \0 instead of replace with eg. space?
this explains it best:
gyscos#778 (comment)

This also fixes warnings about unused Result.

Closes: gyscos#780
correabuscar added a commit to correabuscar/cursive that referenced this issue Jun 2, 2024
...before sending the &str to ncurses backend,
this is done for cursive's print_at() and print_at_rep() only!
otherwise, nothing would get printed, silently.

Why delete \0 instead of replace with eg. space?
this explains it best:
gyscos#778 (comment)

This also fixes warnings about unused Result.

Closes: gyscos#780
correabuscar added a commit to correabuscar/cursive that referenced this issue Jun 5, 2024
...before sending the &str to ncurses backend,
this is done for cursive's print_at() and print_at_rep() only!
otherwise, nothing would get printed, silently.

Why delete \0 instead of replace with eg. space?
this explains it best:
gyscos#778 (comment)

This also fixes warnings about unused Result.

Closes: gyscos#780
correabuscar added a commit to correabuscar/cursive that referenced this issue Jun 5, 2024
...before sending the &str to ncurses backend,
this is done for cursive's print_at() and print_at_rep() only!
otherwise, nothing would get printed, silently.

Why delete \0 instead of replace with eg. space?
this explains it best:
gyscos#778 (comment)

This also fixes warnings about unused Result.

Closes: gyscos#780
@correabuscar

This comment was marked as outdated.

@correabuscar

This comment was marked as resolved.

@gyscos
Copy link
Owner

gyscos commented Jun 6, 2024

The crash should now be fixed with the latest commit, which ignores \0 (when using unicode-width < 0.1.13), or replaces it with (when using unicode-width >= 0.1.13).

Note that on my terminal, the handling of is a bit buggy: it is treated as a single-width character, but is rendered as a double-width one: this is on Alacritty 0.13.2:

screenshot issue 780

The same happens on gnone-terminal. Might depend on the font used. This happens both with monospace and with Source code pro. Ah - with Ubuntu Mono it looks good! On a macOS terminal with the default font, it also looks properly single-width. 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants