Comments (4)
I am all for adding proper UTF-16 support but this particular issue is nothing to do with conversion
context.attach('echo', proc{|v| return v })
Should be
context.attach('echo', proc{|v| v })
return from a proc has very very confusing semantics ...
irb(main):007:0> @my_proc = proc{return "hi"}
=> #<Proc:0x007f211dbad7c8@(irb):7>
irb(main):008:0> def x; puts 1; @my_proc.call; puts 2; end
=> :x
irb(main):009:0> x
1
LocalJumpError: unexpected return
vs
irb(main):010:0> @my_lambda = lambda{return "hi"}
=> #<Proc:0x007f211db7ded8@(irb):10 (lambda)>
irb(main):011:0> def x; puts 1; @my_lambda.call; puts 2; end
=> :x
irb(main):012:0> x
1
2
=> nil
Use lambdas, not procs
from mini_racer.
Indeed, I'm not able to repro the issue with this simplified test, which means it's probably in my ruby code on the other side of the attached method somewhere.
Looks like after adjusting the test case, the 'malformed utf8' can travel safely to and from rubyland as I assume you discovered after fixing my typo.
I also have added some code to strip out invalid utf8 chars coming in from JS as a post-process operation.
There's probably a better way (use utf-16 encoded strings being passed into attached methods? maybe?)
Anyhow. Thanks for the assist.
from mini_racer.
I am totally open to adding utf16 support but it gets pretty hairy and we would need to be super careful not to make all string handling slower just cause we add support for it.
from mini_racer.
Yeah, it's a tough proposition, because in terms of stability, having all the strings that are passed into attached methods matching JS string formats should reduce friction at this barrier- but utf16 is definitely a heftier encoding--
does seem like it would be more performant to not change the encoding of the strings when traveling between rb&js though.
from mini_racer.
Related Issues (20)
- After MacOS Ventura upgrade. gem install works, bundle install does not HOT 2
- Context has no Isolate available anymore HOT 3
- bundler install error HOT 5
- Installing mini_racer 0.6 on docker M1 fails with "make: printf: Argument list too long" HOT 4
- Update default branch to `main` HOT 3
- Unexpected token p in JSON at position HOT 2
- Gem::Ext::BuildError: ERROR: Failed to build gem native extension (Ruby 2.7.4) HOT 3
- Discuss: Release version 1.0.0 and manage consumer breaking version expectations HOT 3
- Node release catch-up plan HOT 42
- CI Improvements HOT 1
- `Isolate::low_memory_notification` fails to lock Isolate HOT 5
- Error installing mini_racer: ERROR: Failed to build gem native extension HOT 7
- Undefined Conversion
- Segmentation fault when application stops (Ruby 3.2.2, tcmalloc or jemalloc) HOT 17
- mini_racer not starting: `ZSt28__throw_bad_array_new_lengthv: symbol not found (LoadError)` HOT 9
- Suggestions for context defaults for server side rendering HOT 4
- Security guarantees? HOT 1
- mini_racer 0.12.0 Segmentation fault on x86_64-linux with libv8-node 21.7.2.0 HOT 101
- Using IO or rescuing exceptions when setting a timeout HOT 3
- mini_racer can't install on ubuntu 24 using ruby 3.2.3 and bundler 2.5.13 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mini_racer.