vaadin / vaadin-rich-text-editor-flow

Other
1 stars 3 forks source link

Invalid JSON gets passed as a value #80

Closed mvysny closed 4 years ago

mvysny commented 4 years ago

rich-text-flow 2.1.0; Vaadin 14.0.12

In my app, I was mistakenly creating new RichTextEditor("Text:"); (I thought Text: is the label, yet it's not #44 ).

In certain cases (which I can't unfortunately currently reproduce outside of my app), the Text: string gets passed into the client-side component as a JSON, which is then failed to be parsed:

Screenshot from 2019-11-19 15-09-36

The stacktrace is then as follows:

Invalid value set to rich-text-editor: SyntaxError: "JSON.parse: unexpected character at line 1 column 1 of the JSON data"
    node_modules vaadin/vaadin-rich-text-editor/src/vaadin-rich-text-editor.js?babel-target=es6:927
    node_modules polymer/polymer/lib/mixins/property-effects.js?babel-target=es6:927
    node_modules polymer/polymer/lib/mixins/property-effects.js?babel-target=es6:178
    node_modules polymer/polymer/lib/mixins/property-effects.js?babel-target=es6:138
    node_modules polymer/polymer/lib/mixins/property-effects.js?babel-target=es6:1898
    _propertiesChanged http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988
    node_modules polymer/polymer/lib/mixins/properties-changed.js?babel-target=es6:396
    node_modules polymer/polymer/lib/mixins/property-effects.js?babel-target=es6:1726
    node_modules polymer/polymer/lib/mixins/property-effects.js?babel-target=es6:1692
    node_modules polymer/polymer/lib/mixins/property-effects.js?babel-target=es6:1676
    node_modules polymer/polymer/lib/mixins/properties-changed.js?babel-target=es6:169
    node_modules vaadin/vaadin-rich-text-editor/src/vaadin-rich-text-editor.js?babel-target=es6:420
    ready http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988
    node_modules polymer/polymer/lib/mixins/properties-changed.js?babel-target=es6:372
    node_modules polymer/polymer/lib/mixins/properties-mixin.js?babel-target=es6:244
    node_modules polymer/polymer/lib/mixins/element-mixin.js?babel-target=es6:684
    xv http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:944
    Pv http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:906
    Rx http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988
    oA http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:870
    $q http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:983
    pr http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988
    Ej http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:396
    Sq http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:984
    Tq http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:968
    gt http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988
    UA http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988
    onreadystatechange http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:572
    sb http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:421
    vb http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:856
    ub http://localhost:8080/VAADIN/static/client/client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:585
mvysny commented 4 years ago

There is the following in the UIDL: {"node":917,"type":"put","key":"value","feat":1,"value":"Text:"} which looks wrong (since the value should be the Delta JSON). That leads me to believe that the problem is server-side.

mvysny commented 4 years ago

Ah crap:

     * @param initialValue
     *            the initial value in Delta format, not {@code null}

Okay, my bad, sorry :) Still, it would be great if the Delta format was validated server-side, you know, fail fast...