Illegal XML characters

11 posts, 0 answers
  1. henk
    henk avatar
    6 posts
    Member since:
    Oct 2011

    Posted 20 Nov 2015 Link to this post

    Hello,

     Is there some option in the ReportProcessor to automatically ignore illegal XML characters, like ascii control characters?

     

    Regards

  2. Stef
    Admin
    Stef avatar
    3611 posts

    Posted 20 Nov 2015 Link to this post

    Hello Henk,

    An XML serialization error may occur if the report is created by a Report Designer of greater Telerik Reporting version than the used in the application. Other possible reasons is the used data in the report.

    Please elaborate on the error message, the used Telerik Reporting version, and post the TRDX file's content.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. henk
    henk avatar
    6 posts
    Member since:
    Oct 2011

    Posted 20 Nov 2015 Link to this post

    The error is caused by a control character in the usder supplied data (in this case the character 'Record Separator' which corresponds to 0x1E or 30 in decimal). This is illegal with respect to the XML standard and thus cannot be parsed without being escaped (or removed).

    Now, since I/we don't have full control over user input due to legacy issues, I was wondering if there's a setting to ignore these sort of characters (the entire range of invalid XML characters) so the report generator won't stop with an exception.

  4. henk
    henk avatar
    6 posts
    Member since:
    Oct 2011

    Posted 20 Nov 2015 in reply to henk Link to this post

    Since it's not possible to edit my post, we are using version 'Q1 2013 build 7.0.13.228' of Telerik.Reporting.
  5. Stef
    Admin
    Stef avatar
    3611 posts

    Posted 20 Nov 2015 Link to this post

    Hi Henk,

    If the error occurs on processing the report, the data can be escaped in the data-retrieval method or in the report.
    In reports you can use the built-in Text functions or custom ones to handle the retrieved data, where custom functions have to be loaded from an external assembly in the Standalone designer (Extending Report Designer).

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. henk
    henk avatar
    6 posts
    Member since:
    Oct 2011

    Posted 21 Nov 2015 Link to this post

    So, you still haven't answered my question. Is there a built-in that can handle this?

    It seems like software immaturity to me if the report engine fails on disallowed characters. Having to escape all data by myself implies a lot of work which should be handled by the framework.

  7. Stef
    Admin
    Stef avatar
    3611 posts

    Posted 23 Nov 2015 Link to this post

    Hi Henk,

    I am uncertain what is the exact error and what causes it. The listed approaches for escaping the report's data can help in case data contains invalid characters (e.g. HTML used by an HtmlTextBox item).

    In order to provide you more accurate suggestions, please post test data and the report's definition (code), which will allow us to perform local tests. Include also a screenshot of the error, the exception stack trace and details where and when the error occurs (in a designer, in an application).

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. henk
    henk avatar
    6 posts
    Member since:
    Oct 2011

    Posted 23 Nov 2015 in reply to Stef Link to this post

    The exact error is that there are illegal characters in some user supplied data, in this case one of the control characters (hex: 0x1E).

    ReportProcessor.RenderReport can't handle these characters and throws an ArgumentException {"'', hexadecimal value 0x1E, is an invalid character."}. 

    Since I have no control over what users are putting in to the system due to legacy reasons (i.e. I can't control their input and since it's a SOA a server-side check is needed in any case).

    Somewhere these characters need to be filtered out (or escaped properly). Now surely I can walk the object tree recursively and check all strings for these characters, but what I really want is a built-in that does this for me.

  9. henk
    henk avatar
    6 posts
    Member since:
    Oct 2011

    Posted 25 Nov 2015 in reply to henk Link to this post

    Any news? To replicate this, you could bind some datasource with those illegal chacarters en try to generate a report.
  10. Stef
    Admin
    Stef avatar
    3611 posts

    Posted 25 Nov 2015 Link to this post

    Hi Henk,

    Lets assume the user's input is: <aaa>bbb&#30;ccc</aaa>. This value will be loaded in the report via expression based on a fields from the data source e.g. Fields.UserInput.

    You can escape this string before setting it as an HtmlTextBox.Value as follows:
    In Q3 2015 and later by using the HtmlEncode utility function:
    = HtmlEncode(Fields.UserInput)

    In Q1 2013, you can use a custom function which extends the Standalone Report Designer (Extending Report Designer), or escape the data on retrieval by encoding the value or replacing illegal characters


    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  11. Wojciech
    Wojciech avatar
    1 posts
    Member since:
    Oct 2017

    Posted 06 Oct in reply to henk Link to this post

    Hi henk,

    have you found answer/solution for your problem. I've got exactly the same situation. And I'm not gonna check every property on every object to replace invalid characters...

     

    Thank in advance.

Back to Top