-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add extended clipboard Pseudo-Encoding #1366
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3b562e8
Make clipBoardPasteFrom() test more specific
CendioNiko f52e979
Add deflator helper class for deflating data
CendioNiko 9575ded
Add util for unsigned and signed int. conversion
CendioNiko 183cab0
Remove unused inflate argument
CendioNiko fe5aa64
Add missing copyright header for Inflator.js
CendioNiko f6669ff
Move error handling to Inflate class
CendioNiko 3cf1100
Handle errors from zlib/pako
CendioNiko 2cee106
Split api of inflate
CendioNiko 13be552
Fix bug where inflate would read too much data
CendioNiko 9a31083
Export constants in inflate.js for easier usage
CendioNiko f73fdc3
Add extended clipboard Pseudo-Encoding
CendioNiko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* noVNC: HTML5 VNC client | ||
* Copyright (C) 2020 The noVNC Authors | ||
* Licensed under MPL 2.0 (see LICENSE.txt) | ||
* | ||
* See README.md for usage and integration instructions. | ||
*/ | ||
|
||
import { deflateInit, deflate } from "../vendor/pako/lib/zlib/deflate.js"; | ||
import { Z_FULL_FLUSH } from "../vendor/pako/lib/zlib/deflate.js"; | ||
import ZStream from "../vendor/pako/lib/zlib/zstream.js"; | ||
|
||
export default class Deflator { | ||
constructor() { | ||
this.strm = new ZStream(); | ||
this.chunkSize = 1024 * 10 * 10; | ||
this.outputBuffer = new Uint8Array(this.chunkSize); | ||
this.windowBits = 5; | ||
|
||
deflateInit(this.strm, this.windowBits); | ||
} | ||
|
||
deflate(inData) { | ||
this.strm.input = inData; | ||
this.strm.avail_in = this.strm.input.length; | ||
this.strm.next_in = 0; | ||
this.strm.output = this.outputBuffer; | ||
this.strm.avail_out = this.chunkSize; | ||
this.strm.next_out = 0; | ||
|
||
let lastRet = deflate(this.strm, Z_FULL_FLUSH); | ||
let outData = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out); | ||
|
||
if (lastRet < 0) { | ||
throw new Error("zlib deflate failed"); | ||
} | ||
|
||
if (this.strm.avail_in > 0) { | ||
CendioNiko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Read chunks until done | ||
|
||
let chunks = [outData]; | ||
let totalLen = outData.length; | ||
do { | ||
this.strm.output = new Uint8Array(this.chunkSize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to reset |
||
this.strm.next_out = 0; | ||
this.strm.avail_out = this.chunkSize; | ||
|
||
lastRet = deflate(this.strm, Z_FULL_FLUSH); | ||
|
||
if (lastRet < 0) { | ||
throw new Error("zlib deflate failed"); | ||
} | ||
|
||
let chunk = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out); | ||
totalLen += chunk.length; | ||
chunks.push(chunk); | ||
} while (this.strm.avail_in > 0); | ||
|
||
// Combine chunks into a single data | ||
|
||
let newData = new Uint8Array(totalLen); | ||
let offset = 0; | ||
|
||
for (let i = 0; i < chunks.length; i++) { | ||
newData.set(chunks[i], offset); | ||
offset += chunks[i].length; | ||
} | ||
|
||
outData = newData; | ||
} | ||
|
||
this.strm.input = null; | ||
this.strm.avail_in = 0; | ||
this.strm.next_in = 0; | ||
|
||
CendioNiko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return outData; | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.