h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.9k stars 323 forks source link

A ValueError is thrown if the websocket message from the client contains data with spaces #2344

Closed martinlie closed 3 weeks ago

martinlie commented 3 weeks ago

Wave SDK Version, OS

H2O Lightwave v1.2.0, Windows

Actual behavior

A ValueError is thrown if the websocket message from the client contains data with spaces.

Expected behavior

JSON with spaces should be accepted as data.

Steps To Reproduce

  1. Add the following control to a page
q.page['example'] = ui.form_card(
            box='tools',
            items=[
                  ui.textbox(name='textbox', label='Standard'),
                  ui.button(name='button', label='Button')
            ]
      )
  1. In the text box, type in a sentence with at least one space, e.g.: "This test"
  2. Press Button
  3. See error: ValueError is thrown because the message is split into four parts

Proposed change

In the file wave/blob/main/py/h2o_lightwave/h2o_lightwave/server.py, function _parse_msg(), the max split is set to 3, but should be 2 (resulting in 3 parts).

Python documentation for str.split():

If maxsplit is given, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements).