SetHtmlRepresentation(this, string htmlRepresentation) doesn't tolerate spaces or control characters

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
Sesztak
Posts: 172
Joined: Fri Jun 24, 2016 2:19 am

SetHtmlRepresentation(this, string htmlRepresentation) doesn't tolerate spaces or control characters

Postby Sesztak » Wed Oct 12, 2016 12:39 am

Dear JS-Support,

We do not know it is a bug or not, but annoying:
in SetHtmlRepresentation(this, string htmlRepresentation) the string htmlRepresentation doesn't tolerate spaces or control characters.

spaces or control characters (like new line): exception in Simulator:
"DESCRIPTION: Uncaught SyntaxError: Unexpected token ILLEGAL"

Other control characters: exception at Browser.

e.g.
working -without exception:
string html = @"<table id=""table_id"" class=""display""><thead><tr><th>Firstname</th><th>Lastname</th><th>Age</th></thead><tbody></tr><tr><td>Jill</td><td>Smith</td><td>50</td></tr><tr><td>Eve</td><td>Péter</td><td>94</td></tr></tbody></table>";

NOT working -exception:

string html = @"
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>";


CSharpXamlForHtml5.DomManagement.SetHtmlRepresentation(this, html);

(Note: the above code is a sample only (using <thead> and <tbody> tags from a 3rd party js lib -but it is not relevant concerning the topic)

What we recommend to you:
-It's should be better to source code formatting & readability to allow formatted string htmlRepresentation,
-you should remove the control characters automatically immediately before build process.

e.g.:
public static string RemoveControlCharacters(string inString)
{
if (inString == null) return null;
StringBuilder newString = new StringBuilder();
char ch;
for (int i = 0; i < inString.Length; i++)
{
ch = inString[i];
if (!char.IsControl(ch))
{
newString.Append(ch);
}
}
return newString.ToString();
}

What do you think ?

We share it as we hope to help others.

Waiting for your kind reply,
Best Regards,
Péter

Sesztak
Posts: 172
Joined: Fri Jun 24, 2016 2:19 am

Re: SetHtmlRepresentation(this, string htmlRepresentation) doesn't tolerate spaces or control characters

Postby Sesztak » Wed Oct 12, 2016 12:44 am

sorry -it is not relevant, just to be precise: we forget to double quote, the not working / exception code again:
(the exception what we mention is not coming from missing double quote )

NOT working -exception:

string html = @"
<table id=""table_id"" class=""display"">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>";

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: SetHtmlRepresentation(this, string htmlRepresentation) doesn't tolerate spaces or control characters

Postby JS-Support @Userware » Wed Oct 12, 2016 4:32 am

Thanks Péter, we are going to do as you recommended. I'll keep you updated.

Regards,
JS-Support


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 22 guests

 

 

cron