libdot: wc: fix substring handling of surrogate pairs

The lib.wc.strWidth function was operating on codeunits (charCodeAt)
instead of codepoints (codePointAt) causing it to incorrectly count
and split surrogate pairs.  This doesn't normally matter as JS uses
UTF-16 for strings which means the two are the same for codepoints
in U+FFFF and lower (which are the most common), but when processing
codepoints higher than that (like U+2099d 𠦝 or U+1f60e 😎), we would
chop off a following character one too earlier.

Rewrite the function to operate on codepoints like we already do in
lib.wc.strWidth.

BUG=chromium:757476

Change-Id: I5891f56bcf1b26bc5639ee88c25de8560c1fd0cf
Reviewed-on: https://chromium-review.googlesource.com/624195
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Brandon Gilmore <varz@google.com>
2 files changed
tree: 6d9aa02cdc3cd9d8fc1ad29f0f339002936ef620
  1. hterm/
  2. libdot/
  3. nassh/
  4. saltpig/
  5. ssh_client/
  6. wam/
  7. wash/
  8. .gitignore
  9. HACK.md
  10. LICENSE
  11. package.json
  12. README.md
README.md

Hello

This repository contains the libdot JavaScript library and some web applications that make use of it.

The official copy of this repository is hosted at https://chromium.googlesource.com/apps/libapps.

There is also a mirror on github at https://github.com/libapps/libapps-mirror. Keep in mind that this mirror may occasionally be behind the official repository.

All changes must go through the Gerrit code review server on https://chromium-review.googlesource.com. Github pull requests cannot be accepted. Please see the HACK.md document in this directory for the details.

Top level directories

  • libdot/ is a small set of JS libraries initially developed as part of hterm, now available as shared code. It provides a base layer for web applications. The code is intended to work in any modern browser, in either a plain web page or a “privileged” environment such as a Chrome platform application or Firefox extension. In practice, it's only been put to use in Chrome platform applications so far.

  • hterm/ is a JS library that provides a terminal emulator. It is reasonably fast, reasonably correct, and reasonably portable across browsers.

  • nassh/ is the Secure Shell Chrome App (currently a “v1.5” app, soon to become a “v2” or platform app) that combines hterm with a NaCl build of OpenSSH to provide a PuTTY-like app for Chrome users.

  • ssh_client/ is the NaCl port of OpenSSH. It is used by nassh to create the Secure Shell App.

  • wash/ is a library for cross-origin virtual filesystems, similar to the Plan 9 filesystem. This directory also contains a simple bash-like shell environment for exploring these filesystems. The code in this directory is a work-in-progress.