You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by "mike-jumper (via GitHub)" <gi...@apache.org> on 2023/05/05 18:00:38 UTC

[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #853: GUACAMOLE-615: Correct potential parse failures in webapp parser implementations.

mike-jumper commented on code in PR #853:
URL: https://github.com/apache/guacamole-client/pull/853#discussion_r1186367743


##########
guacamole-common-js/src/main/webapp/modules/Parser.js:
##########
@@ -63,80 +92,135 @@ Guacamole.Parser = function() {
      *
      * @param {!string} packet
      *     The instruction data to receive.
+     *
+     * @param {!boolean} [isBuffer=false]
+     *     Whether the provided data should be treated as an instruction buffer
+     *     that grows continuously. If true, the data provided to receive()
+     *     MUST always start with the data provided to the previous call. If
+     *     false (the default), only the new data should be provided to
+     *     receive(), and previously-received data will automatically be
+     *     buffered by the parser as needed.
      */
-    this.receive = function(packet) {
+    this.receive = function receive(packet, isBuffer) {
 
-        // Truncate buffer as necessary
-        if (start_index > 4096 && element_end >= start_index) {
+        if (isBuffer)
+            buffer = packet;
 
-            buffer = buffer.substring(start_index);
+        else {
 
-            // Reset parse relative to truncation
-            element_end -= start_index;
-            start_index = 0;
+            // Truncate buffer as necessary
+            if (startIndex > 4096 && elementEnd >= startIndex) {

Review Comment:
   Sure, I'll add that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org