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

panicked at 'malformed Unicode character escape sequence: Utf8Error { valid_up_to: 3, error_len: None }' #1399

Closed
charlesxsh opened this issue Jul 16, 2021 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@charlesxsh
Copy link

charlesxsh commented Jul 16, 2021

Describe the bug
thread 'main' panicked at 'malformed Unicode character escape sequence: Utf8Error { valid_up_to: 3, error_len: None }'

To Reproduce
Input:
Th"}f\ua/ ڀ

Code:

fn main(){
    // let data = input

    let mut context = Context::new();
    context.eval(data);

}

Output

thread 'main' panicked at 'malformed Unicode character escape sequence: Utf8Error { valid_up_to: 3, error_len: None }', /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/lexer/string.rs:159:38
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: core::result::Result<T,E>::expect
             at /home/xsh/code/rust-compiler/src/libcore/result.rs:963
  10: boa::syntax::lexer::string::unescape_string
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/lexer/string.rs:158
  11: <boa::syntax::lexer::string::StringLiteral as boa::syntax::lexer::Tokenizer<R>>::lex
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/lexer/string.rs:61
  12: boa::syntax::lexer::Lexer<R>::next
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/lexer/mod.rs:200
  13: boa::syntax::parser::cursor::buffered_lexer::BufferedLexer<R>::fill
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/cursor/buffered_lexer/mod.rs:131
  14: boa::syntax::parser::cursor::buffered_lexer::BufferedLexer<R>::peek
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/cursor/buffered_lexer/mod.rs:219
  15: boa::syntax::parser::cursor::Cursor<R>::peek
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/cursor/mod.rs:61
  16: <boa::syntax::parser::statement::Statement as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:184
  17: <boa::syntax::parser::statement::StatementListItem as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:353
  18: <boa::syntax::parser::statement::StatementList as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:274
  19: <boa::syntax::parser::ScriptBody as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/mod.rs:159
  20: <boa::syntax::parser::Script as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/mod.rs:136
  21: boa::syntax::parser::Parser<R>::parse_all
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/mod.rs:105
  22: boa::context::Context::eval
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/context.rs:712

Expected behavior
eval should return error properly instead of panic

Build environment (please complete the following information):

  • OS: Ubuntu
  • Version: 18.04
  • Target triple: x86_64-unknown-linux-gnu
  • Rustc version: rustc 1.46.0

Additional context
Add any other context about the problem here.

@charlesxsh charlesxsh added the bug Something isn't working label Jul 16, 2021
@Razican Razican added this to the v0.14.0 milestone Jan 31, 2022
@Razican Razican self-assigned this Jan 31, 2022
@Razican Razican modified the milestones: v0.14.0, v0.13.0, v0.12.0 Feb 5, 2022
@Razican
Copy link
Member

Razican commented Feb 5, 2022

This was fixed in #1079, and released in the v0.12 version.

@Razican Razican closed this as completed Feb 5, 2022
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

2 participants