context: Fix gjs_context_eval() for non-zero-terminated strings

Calling gjs_context_eval() with a non-zero-terminated string has
apparently been broken for quite a long time. I guess nobody ever does
that.

This is a surprisingly complicated fix for a simple-sounding problem.
The complication is due to the passed-in strlen being ignored in more
than one place: both in gjs_strip_unix_shebang() and in the code that
converts UTF-8 to UTF-16.

In addition, gjs_strip_unix_shebang() would access invalid memory if
given a 1-length string or a non-zero-terminated string.

We fix the UTF-16 conversion code, and replace gjs_strip_unix_shebang()
with a safer version using C++ strings (which we have anyway after
converting to UTF-16.) This new function, gjs_unix_shebang_len(),
returns the offset that must be added to the string's starting position,
in order to skip the shebang line.

It would be better in the future to return a std::u16string_view from
gjs_unix_shebang_len(), but that is not yet available in C++14.

This bug was found by compiling with -Wunused-parameter!
27 jobs for fix-gjs-context-eval in 10 minutes and 17 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Source Check
passed #263063
cppcheck

00:01:08

passed #263064
cpplint

00:01:35

passed #263065
eslint

00:01:14

passed #263062
fedora

00:03:01

 
  Test
passed #263069
no_graphics

00:03:50

passed #263070
no_profiler

00:04:09

passed #263071
no_readline

00:04:10

passed #263088
sanitizer_gcc

00:03:00

passed #263067
with_logging

00:04:15

passed #263068
with_systemtap

00:04:15

failed #263066
sanitizer_gcc

00:00:10

 
  Manual
manual #263085
allowed to fail manual
armv8
manual #263072
allowed to fail manual
codequality
manual #263073
allowed to fail manual
code_statistics
manual #263087
allowed to fail manual
coverage
manual #263075
allowed to fail manual
fedora_gcc
manual #263081
allowed to fail manual
flatpak
manual #263076
allowed to fail manual
installed_tests
manual #263079
allowed to fail manual
lts
manual #263086
allowed to fail manual
ppc64le
manual #263074
allowed to fail manual
sanitizer_clang
manual #263078
allowed to fail manual
ubuntu_clang
manual #263077
allowed to fail manual
ubuntu_gcc
manual #263080
allowed to fail manual
valgrind
manual #263084
allowed to fail manual
zeal_11
manual #263082
allowed to fail manual
zeal_2
manual #263083
allowed to fail manual
zeal_4