Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333143

Summary: Javascript error if set text with special characters to Text component
Product: [RT] RAP Reporter: Yury <swimmer_86>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: Istvan.Ballok, ruediger.herrmann, swimmer_86
Version: 1.3   
Target Milestone: 1.4 M5   
Hardware: PC   
OS: All   
Whiteboard:

Description Yury CLA 2010-12-23 06:11:40 EST
Build Identifier: RAP 1.3

This bug is close related with https://bugs.eclipse.org/bugs/show_bug.cgi?id=304364.
It is hard to provide steps to reproduce, but the cause of this bug is pretty clear:
i think we should truncate(or replace) zeros while set text to Text component
in JSWriter also:

  private static String escapeString( final String input ) {
    String result = EncodingUtil.escapeDoubleQuoted( input );
    result = EncodingUtil.replaceNewLines( result );

    int index = result.indexOf( 0 );
    if( index != -1 ) {
      result = result.substring( 0, index );
    }
    return result;
  }

As it is made for Labels in WidgetLCAUtil:

  public static String escapeText( final String text, final boolean mnemonics )
  {
    ...
    // truncate at zeros
    String result = buffer.toString();
    int index = result.indexOf( 0 );
    if( index != -1 ) {
      result = result.substring( 0, index );
    }
    return result;
  }

Reproducible: Always
Comment 1 Ivan Furnadjiev CLA 2011-01-28 05:54:33 EST
I did some tests in different browsers - FF, Safari, Chrome and Opera automatically truncate the text at zero, IE crashed with "undetermined string constant" error. Text is truncated at zero in TextLCAUtil as suggested. Changes are in CVS HEAD.