Crashes if any of your property descriptions contain a quote character.
First, thank you for such an excellent package! Really simplifies things for our clients when we can hide certain inherited tabs/props that aren't used by a particular document, instead of them wondering "what's this for?"
With that said, we did run into a crash as soon as we installed it. I tracked this down to what looks like invalid JSON being produced which is not propertly escaping/encoding the quote character. Here is how to reproduce:
1. Create a property on your document type, and give it a description that contains a quote character. Like this:
secondaryContent: This content will appear below the "widget" region on your page. (or whatever.)
2. Now try and edit a document and observe the crash.
The problem is that the quotes around "widget" are not being encoded/escaped. We "fixed" this problem by revising our property descriptions to use apostrophes instead of quotes.
Hopefully this leads to a fix and/or to help anyone else having this problem. Thank you!
This is with the latest uHidesy 1.13 downloaded today, on a fresh 4.7.1 installation.
Question: does uHidesy do something special the very first time you view the Content section? What is strange is that I have put the quotes back into the property's description that I mentioned was the problem, and now cannot get anything to crash!
I am sure I was not imagining the crash: the yellow screen of death showed me a big JSON mess that I analyzed and discovered would not parse. Swapping the quotes with apostrophes fixed the problem.
Maybe my order of events is wrong for reproducing. I haven't yet tested this but this is more accurate as how I first encountered: On a fresh 4.7.1 "pre-uHidesy" installation, create your property with a description containing some quote characters as I described above. THEN install uHidesy, add its DataType to your doc type and surf on over to your Content section and try to edit one of the nodes. That is why I was wondering if uHidesy does any special "initialization" steps when it first installs?
OK I thought I had lost the original error and it drives me nuts I can't reproduce this, but found this in the server logs:
Exception message: Invalid object passed in, ':' or '}' expected. at uHidesy.Umbraco.usercontrols.uHidesy.uHidesy.SaveSettings() in D:\_PROJECTS\uHidesy - Property Hider\Branches\1.13_noDesc\Umbraco.Web\usercontrols\uHidesy\uHidesy.ascx.cs:line 173 at uHidesy.Umbraco.usercontrols.uHidesy.uHidesy.OnLoad(EventArgs e) in D:\_PROJECTS\uHidesy - Property Hider\Branches\1.13_noDesc\Umbraco.Web\usercontrols\uHidesy\uHidesy.ascx.cs:line 38
Below is also the relevant part of the invalid parameter, whch looks like a JSON structure showing the invalid quote character + unexpected linebreak in the "Article Teaser" description:
{
"document": {
"id": 1092,
"documentType": "newsArticle",
"tabs": [{
"name": "News Article",
"index": 0,
"properties": [{
"name": "Article Display Date",
"index": 0,
"status": "show"
}, {
"name": "Article Teaser<BR><SMALL>Optional. Will appear secondary to the "
article title " if entered.</SMALL>",
"index": 0,
"status": "show"
}, {
"name": "Article Author<BR><SMALL>This field is optional.</SMALL>",
"index": 0,
"status": "show"
}, {
"name": "Article Body<BR><SMALL>The main content of your news article.</SMALL>",
"index": 0,
"status": "show"
}],
"status": "show"
}, {
...............
So it seems the "name" of each property isn't just the name: it also includes "<BR><SMALL>" + description + "</SMALL>", the description of which seems to be the trouble-maker in need of escaping. The "status:show" leads me to suspect this is something uHidesy generated?
I have the same error, and it can re-produced in IE9 clean on windows 7 - 32 bit (not sure about 64 bit)
In the SaveSettings() mthod in the uHidesy codebehind, there is a line where a replacement is done: object document = ((Dictionary<string, object>) new JavaScriptSerializer().DeserializeObject(this.uHidesy_value.Value.Replace("\\\"", "\"")))["document"];
The Replace("\\\"", "\"") call makes the json invalid, because the json returned actually still contains json values with \"
The reason the JSON returned is invalid is that in the ascx file's javascript methods in the line: var propertyName = propertyItemheader.length == 0 ? '-Property-name-not-displayed-' : $(propertyItemheader).html(); propertyName = propertyName.indexOf('<small>') == -1 ? propertyName : propertyName.substring(0, propertyName.indexOf('<small>')); The html output from this is in IE html with capital html tags, and then javascript can not find the tag, and just uses all the html, that could contain "\, and thereby making the serverside code fail. To fix it just append .toLowerCase() to the line in the ascx fil, so that it becomes: var propertyName = propertyItemheader.length == 0 ? '-Property-name-not-displayed-' : $(propertyItemheader).html().toLowerCase();
Crashes if any of your property descriptions contain a quote character.
First, thank you for such an excellent package! Really simplifies things for our clients when we can hide certain inherited tabs/props that aren't used by a particular document, instead of them wondering "what's this for?"
With that said, we did run into a crash as soon as we installed it. I tracked this down to what looks like invalid JSON being produced which is not propertly escaping/encoding the quote character. Here is how to reproduce:
1. Create a property on your document type, and give it a description that contains a quote character. Like this:
secondaryContent: This content will appear below the "widget" region on your page. (or whatever.)
2. Now try and edit a document and observe the crash.
The problem is that the quotes around "widget" are not being encoded/escaped. We "fixed" this problem by revising our property descriptions to use apostrophes instead of quotes.
Hopefully this leads to a fix and/or to help anyone else having this problem. Thank you!
Which version of uHidesy do you have?
In the latest version I ignore the description and only have the title.
Unless your property title has those, in which case I'm pretty sure it would crash.
But, people usually put explainations like this in the desc.
Hi,
This is with the latest uHidesy 1.13 downloaded today, on a fresh 4.7.1 installation.
Question: does uHidesy do something special the very first time you view the Content section? What is strange is that I have put the quotes back into the property's description that I mentioned was the problem, and now cannot get anything to crash!
I am sure I was not imagining the crash: the yellow screen of death showed me a big JSON mess that I analyzed and discovered would not parse. Swapping the quotes with apostrophes fixed the problem.
Maybe my order of events is wrong for reproducing. I haven't yet tested this but this is more accurate as how I first encountered: On a fresh 4.7.1 "pre-uHidesy" installation, create your property with a description containing some quote characters as I described above. THEN install uHidesy, add its DataType to your doc type and surf on over to your Content section and try to edit one of the nodes. That is why I was wondering if uHidesy does any special "initialization" steps when it first installs?
OK I thought I had lost the original error and it drives me nuts I can't reproduce this, but found this in the server logs:
Exception message: Invalid object passed in, ':' or '}' expected.
at uHidesy.Umbraco.usercontrols.uHidesy.uHidesy.SaveSettings() in D:\_PROJECTS\uHidesy - Property Hider\Branches\1.13_noDesc\Umbraco.Web\usercontrols\uHidesy\uHidesy.ascx.cs:line 173
at uHidesy.Umbraco.usercontrols.uHidesy.uHidesy.OnLoad(EventArgs e) in D:\_PROJECTS\uHidesy - Property Hider\Branches\1.13_noDesc\Umbraco.Web\usercontrols\uHidesy\uHidesy.ascx.cs:line 38
Below is also the relevant part of the invalid parameter, whch looks like a JSON structure showing the invalid quote character + unexpected linebreak in the "Article Teaser" description:
So it seems the "name" of each property isn't just the name: it also includes "<BR><SMALL>" + description + "</SMALL>", the description of which seems to be the trouble-maker in need of escaping. The "status:show" leads me to suspect this is something uHidesy generated?
Thank you again!
I cant seem to reproduce this error at all.
uHidesy doesnt do anything special. Just reads from umbracoValue and settings.json.
Maybe something happened to the json file at some point. I cant really say.
I have the same error, and it can re-produced in IE9 clean on windows 7 - 32 bit (not sure about 64 bit)
In the SaveSettings() mthod in the uHidesy codebehind, there is a line where a replacement is done:
object document = ((Dictionary<string, object>) new JavaScriptSerializer().DeserializeObject(this.uHidesy_value.Value.Replace("\\\"", "\"")))["document"];
The Replace("\\\"", "\"") call makes the json invalid, because the json returned actually still contains json values with \"
The reason the JSON returned is invalid is that in the ascx file's javascript methods in the line:
var propertyName = propertyItemheader.length == 0 ? '-Property-name-not-displayed-' : $(propertyItemheader).html();
propertyName = propertyName.indexOf('<small>') == -1 ? propertyName : propertyName.substring(0, propertyName.indexOf('<small>'));
The html output from this is in IE html with capital html tags, and then javascript can not find the tag, and just uses all the html, that could contain "\, and thereby making the serverside code fail. To fix it just append .toLowerCase() to the line in the ascx fil, so that it becomes:
var propertyName = propertyItemheader.length == 0 ? '-Property-name-not-displayed-' : $(propertyItemheader).html().toLowerCase();
Thanks for the bug report.
is working on a reply...