This is a migrated thread and some comments may be shown as answers.

Illegal XML characters

10 Answers 316 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
henk
Top achievements
Rank 1
henk asked on 20 Nov 2015, 12:47 PM

Hello,

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

 

Regards

10 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 20 Nov 2015, 01:21 PM
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
0
henk
Top achievements
Rank 1
answered on 20 Nov 2015, 01:29 PM

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.

0
henk
Top achievements
Rank 1
answered on 20 Nov 2015, 01:32 PM
Since it's not possible to edit my post, we are using version 'Q1 2013 build 7.0.13.228' of Telerik.Reporting.
0
Stef
Telerik team
answered on 20 Nov 2015, 04:21 PM
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
0
henk
Top achievements
Rank 1
answered on 21 Nov 2015, 12:11 PM

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.

0
Stef
Telerik team
answered on 23 Nov 2015, 08:11 AM
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
0
henk
Top achievements
Rank 1
answered on 23 Nov 2015, 09:27 AM

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.

0
henk
Top achievements
Rank 1
answered on 25 Nov 2015, 01:43 PM
Any news? To replicate this, you could bind some datasource with those illegal chacarters en try to generate a report.
0
Stef
Telerik team
answered on 25 Nov 2015, 04:56 PM
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
0
Wojciech
Top achievements
Rank 1
answered on 06 Oct 2017, 12:30 PM

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.

Tags
General Discussions
Asked by
henk
Top achievements
Rank 1
Answers by
Stef
Telerik team
henk
Top achievements
Rank 1
Wojciech
Top achievements
Rank 1
Share this question
or