Skip to content

Commit

Permalink
[split] finagle-http dtab: don't emit (illegal) newlines in lengthy d…
Browse files Browse the repository at this point in the history
…tab header values CSL-996

RB_ID=403381
  • Loading branch information
Matt Landis authored and CI committed Jul 17, 2014
1 parent 9e7677e commit 1edfba5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ object HttpDtab {

private def encodeValue(v: String): String = {
val buf = ChannelBuffers.wrappedBuffer(v.getBytes(Utf8))
val buf64 = Base64.encode(buf)
val breakLines = false // don't want newlines in http headers
val buf64 = Base64.encode(buf, breakLines)
buf64.toString(Ascii)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ class HttpDtabTest extends FunSuite {
assert(Equiv[Dtab].equiv(dtab, dtab1))
}
}

// some base64 encoders insert newlines to enforce max line length. ensure we aren't doing that
test("long dest round-trips") {
val expectedDtab = Dtab.read("/s/a => /s/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
val m = newMsg()
HttpDtab.write(expectedDtab, m)
val observedDtab = HttpDtab.read(m)
assert(Equiv[Dtab].equiv(expectedDtab, observedDtab))
}

test("Invalid: no shared prefix") {
val m = newMsg()
Expand Down

0 comments on commit 1edfba5

Please sign in to comment.