Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.2
-
Fix Version/s: 3.0
-
Component/s: ACE-Components
-
Labels:None
-
Environment:ACE
-
Assignee Priority:P1
Description
Alter how javascript parameters are created, from:
String params = "'" + clientId + "'," +
JSONBuilder.create().
beginMap().
entry("menu", clientId+"_buttonselect").
endMap().toString()
+ "," +
JSONBuilder.create().
beginMap().
entry("ariaEnabled", EnvUtils.isAriaEnabled(facesContext)).
endMap().toString();
String finalScript = "ice.component.menubutton.updateProperties(" + params + ");";
to something like:
String finalScript = JSONBuilder.create().
beginFunction("ice.component.menubutton.updateProperties").
entry(clientId).
beginMap().
entry("menu", clientId+"_buttonselect").
endMap().
comma().
beginMap().
entry("ariaEnabled", EnvUtils.isAriaEnabled(facesContext)).
endMap().
endFunction().semicolon().toString();
There will be less intermediary Object creation, the code will be cleaner, and any other parameters to the function will be properly escaped. Have to add the appropriate beginFunction(-) / endFunction(-) methods, and test the implementation on a component renderer.
String params = "'" + clientId + "'," +
JSONBuilder.create().
beginMap().
entry("menu", clientId+"_buttonselect").
endMap().toString()
+ "," +
JSONBuilder.create().
beginMap().
entry("ariaEnabled", EnvUtils.isAriaEnabled(facesContext)).
endMap().toString();
String finalScript = "ice.component.menubutton.updateProperties(" + params + ");";
to something like:
String finalScript = JSONBuilder.create().
beginFunction("ice.component.menubutton.updateProperties").
entry(clientId).
beginMap().
entry("menu", clientId+"_buttonselect").
endMap().
comma().
beginMap().
entry("ariaEnabled", EnvUtils.isAriaEnabled(facesContext)).
endMap().
endFunction().semicolon().toString();
There will be less intermediary Object creation, the code will be cleaner, and any other parameters to the function will be properly escaped. Have to add the appropriate beginFunction(-) / endFunction(-) methods, and test the implementation on a component renderer.
Issue Links
- blocks
-
ICE-6947 Improve new ACE component security with JSONBuilder
- Closed
Augmented JSONBuilder by adding:
Updated CheckboxButton to use the new technique, as an example of the new API.
So for the example in the jira description, this is how that would now look:
String finalScript = JSONBuilder.create().
beginFunction("ice.component.menubutton.updateProperties").
item(clientId).
beginMap().
entry("menu", clientId+"_buttonselect").
endMap().
beginMap().
entry("ariaEnabled", EnvUtils.isAriaEnabled(facesContext)).
endMap().
endFunction().toString();
scratchpad
Subversion 24938