Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site.renderTo writes junk bytes at the end of HTML files. #72

Open
sjrd opened this issue May 28, 2020 · 1 comment
Open

Site.renderTo writes junk bytes at the end of HTML files. #72

sjrd opened this issue May 28, 2020 · 1 comment

Comments

@sjrd
Copy link

sjrd commented May 28, 2020

When I use Site.renderTo, HTML pages are rendered, but they contain junk bytes at the end of the file, after the closing </html>. This is because this line:

val bytes = scala.io.Codec.UTF8.encoder.encode(cb)

returns a ByteBuffer whose internal capacity is greater than the actually written content. Therefore, writing bytes.array() at
write.over(outputRoot/path, bytes.array(), createFolders = true)

also writes junk bytes of the internal array that were never written.

A solution is to slice the array before giving it to write.over:

write.over(outputRoot/path,
  bytes.array().slice(bytes.position(), bytes.limit()), createFolders = true)
@romainreuillon
Copy link
Collaborator

Fixed in the version I maintain: openmole@3dbedae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants