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

node-red-node-ui-table not rendered if a single quote character is in the description (info) #66

Open
7 tasks
wipfl opened this issue May 27, 2021 · 1 comment

Comments

@wipfl
Copy link
Contributor

wipfl commented May 27, 2021

Which node are you reporting an issue on?

nod-red-node-ui-table 0.3.10

What are the steps to reproduce?

  1. Place an ui-table on the dashboard and feed it with some content. Make sure that the table shows the wanted content.
  2. Edit the description of the ui-table and enter a single quote character (').
  3. Deploy again. Now the table is not shown anymore.
    I don't know the exact reason, but somehow a string is send to angular with the full object of the ui-table node. (I can't find the starting single quote!) The single quote character in the info-field of the object terminates this string and then the json lexer can't handle this string anymore. Maybe the stringifier is the base cause.
    To my opinion this is also the reason for the issue node-red-node-ui-table does not render when Name field has a single quote in it #28

Note: Double quotes don't disturb. Single quotes in the table content are also not an issue.

What happens?

The table is not rendered if a single quote character is in the description (info)

What do you expect to happen?

The table should render. The description should have no influence on the behaviour of the node.

A simple work-around would be to remove the info field from the object for this purpose.

Please tell us about your environment:

  • Node-RED version: redmatic 1.2.9
  • node.js version: 12.22.1
  • npm version: 6.14.12
  • Platform/OS: raspberry pi 3b+ / raspberrymatic (open source homematic OS) linux 5.10.17
  • Browser: FF 88.0.1 and Chromium 90.0
  • node-red-dashboard 2.28.1
  • node-red-node-ui-table 0.3.10
@Christian-Me
Copy link
Contributor

Christian-Me commented May 27, 2021

``Hi,

thank you for submitting this issue. Actually this effect can be spotted in other ui-nodes (including my own) following the same scheme for placing the HTML code onto the dashboard.

    function HTML(config) {
       var configAsJson = JSON.stringify(config);
       var html = String.raw`
          <input type='hidden' ng-init='init(` + configAsJson + `)'>
        `;
        return html;
    }

@dceejay : I'm not into regex but after googling perhaps this helps ... (but there must be a better solution to correctly escape inverted commas of all kind correctly) - also as this effect only seams to effect values on first level of the config object (in the columns array they work fine) it is perhaps not necessary to replace all ' apostrophes.

    function HTML(config) {
       var configAsJson = JSON.stringify(config).replace(/[\/\(\)\']/g, "&apos;");
       var html = String.raw`
          <input type='hidden' ng-init='init(` + configAsJson + `)'>
        `;
        return html;
    }

(BTW Now as I know that the info parameter is passed to the dashboard I will perhaps be less generous with long markdowns in my UI nodes 😂)

Simply deleting or excluding the config.info property may fix this but the problem appear in widgets with labels too (config.label)

wipfl added a commit to wipfl/node-red-ui-nodes that referenced this issue Jun 3, 2021
wipfl added a commit to wipfl/node-red-ui-nodes that referenced this issue Jun 3, 2021
dceejay pushed a commit that referenced this issue Jul 8, 2021
* [node-red-node-ui-table] single-quote issue #66

* [ui-table] add test flow for single-quote #66
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