• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TykTechnologies / tyk / 2806

Build:
DEFAULT BRANCH: master
Ran 29 Aug 2017 02:23PM UTC
Jobs 1
Files 84
Run time 8s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
2806

push

travis-ci

mvdan
plugin: marshal body into json as []byte

The encoding/json godoc reads:

	String values encode as JSON strings coerced to valid UTF-8,
	replacing invalid bytes with the Unicode replacement rune.

	... []byte encodes as a base64-encoded string, ...

We need to marshal the body as a []byte, not a string. Since JSON needs
to be valid UTF-8, we can't just keep the bytes as-is.

We can't simply quote the string, as JSON does not have a way to escape
bytes like \xff. It does have \u, but that is only for valid unicode
characters, which binary bytes may not be.

Using []byte in JSON means encoding to base64 in Go, so we must
introduce functions in the JSVM to decode and encode base64. This is so
that JS plugins can replace or modify the body in plaintext, not base64.
This is required for backwards compatibility.

This may or may not work in some JS implementations depending on whether
or not their strings can contain non-UTF8. Luckily, Otto supports that
just fine. We check this via the added test, which has ASCII, non-ASCII
unicode and non-unicode characters in one string that is modified.

Fixes #351.

30 of 30 new or added lines in 1 file covered. (100.0%)

5955 of 13589 relevant lines covered (43.82%)

0.47 hits per line

Uncovered Changes

Lines Coverage ∆ File
15
100.0
plugins.go
Jobs
ID Job ID Ran Files Coverage
2 2806.2 (LATEST_GO=true) 29 Aug 2017 02:22PM UTC 0
43.82
Travis Job 2806.2
Source Files on build 2806
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #2806
  • cec74eea on github
  • Prev Build on master (#2802)
  • Next Build on master (#2817)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc