Hi all,

I would like to modify the code slightly from this patch. Basically, move the check for typeof down, so that it only affects the code which does String.replace(). For details, see TRINIDAD-1036.

I didn't see a test scenario for TRINIDAD-873, so if anyone familiar with the above can i) email me their test case or ii) verify the proposed changes, please let me know.

Thanks,
Yee-Wah
====================================
Original:
function _formatErrorString()
{
..
 for (var currToken in tokens)
 {
   var currValue = tokens[currToken];

   // if the token has no value, replace it with the empty string
   if (!currValue)
   {
     currValue = "";
   }

   // TRINIDAD-829:
   // we replace '{' and '}' to ensure, that tokens containing values
   // like {3} aren't parsed more than once...
   currValue = currValue.replace("{","{'");
   currValue = currValue.replace("}","'}");
}
-------------------------------------------------
With TRINIDAD-873 patch:
function _formatErrorString( )
{
  ..
 for (var currToken in tokens)
 {
   var currValue = tokens[currToken];

+    // if the token has no value
+ // or !typeof string, replace it with the empty string (see TRINIDAD-873)
+    if (!currValue || !(typeof currValue == "string"))
   {
     currValue = "";
   }

   // TRINIDAD-829:
   // we replace '{' and '}' to ensure, that tokens containing values
   // like {3} aren't parsed more than once...
   currValue = currValue.replace("{","{'");
   currValue = currValue.replace("}","'}");
}
-------------------------------------------------
With TRINIDAD-1036 patch:
function _formatErrorString( )
{
  ..
 for (var currToken in tokens)
 {
   var currValue = tokens[currToken];

   // if the token has no value
+    if (!currValue)
   {
      currValue = "";
   }

   // TRINIDAD-829:
   // we replace '{' and '}' to ensure, that tokens containing values
   // like {3} aren't parsed more than once...
+    // Only do this if it is typeof string (see TRINIDAD-873)
+    if (typeof currValue == "string")
+    {
       currValue = currValue.replace("{","{'");
       currValue = currValue.replace("}","'}");
+    }



Matthias Weßendorf (JIRA) wrote:
     [ 
https://issues.apache.org/jira/browse/TRINIDAD-873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Matthias Weßendorf updated TRINIDAD-873:
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2.5-core
                   1.0.5-core
           Status: Resolved  (was: Patch Available)

applied the patch to both trunks;

JavaScriptError in Core.js _formatErrorString
---------------------------------------------

                Key: TRINIDAD-873
                URL: https://issues.apache.org/jira/browse/TRINIDAD-873
            Project: MyFaces Trinidad
         Issue Type: Bug
   Affects Versions: 1.0.5-core
           Reporter: Thomas Spiegl
           Assignee: Matthias Weßendorf
            Fix For: 1.0.5-core, 1.2.5-core

        Attachments: Core.js.patch


currValue in defined in function _formatErrorString line 2807 may be a function 
(eg. removeDuplicates)
currValue.replace will then cause a JavaScript error
adding a typeof fixes the problem
    // if the token has no value or !typeof string, replace it with the empty 
string
    if (!currValue || !(typeof currValue == "string"))
    {
      currValue = "";
    }


Reply via email to