Skip to content

Commit

Permalink
TEIIDDES-2548: Handling NUL character in SQL String
Browse files Browse the repository at this point in the history
* The NUL character can added to an ESCAPE clause using its unicode
  counterpart \u0000 and this is converted by java into \0. This character
  is problematic for printing in any display since printing will terminate
  at the first occurence of NUL.

* Using the SQL editor, users can enter the unicode string into the UI but
  on saving this is converted to \0. The DisplayNode tree still contains
  all nodes after the \0 but printing DisplayNode.toString() terminates too
  soon.

* TextDisplayNode
 * Protect the UI in the text from the \0 by returning \\u0000 (escaped
   version). This will display \u0000 in the UI and save it to the XMI file
   ensuring it can be safely deployed to Teiid.
  • Loading branch information
Paul Richardson committed Jun 17, 2015
1 parent 686fc20 commit 1c6cbb7
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package org.teiid.query.ui.sqleditor.component;


/**
* The <code>TextDisplayNode</code> class is used to represent text display nodes.
*
Expand Down Expand Up @@ -57,7 +58,13 @@ public int setStartIndex(int index) {
*/
@Override
public String toDisplayString() {
return (isVisible() ? this.textStr : BLANK);
if (! isVisible())
return BLANK;

if (textStr.equals("\u0000")) //$NON-NLS-1$
return "\\u0000"; //$NON-NLS-1$

return this.textStr;
}

/**
Expand Down

0 comments on commit 1c6cbb7

Please sign in to comment.