You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2010/04/06 22:09:47 UTC

svn commit: r931301 - /myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js

Author: gcrawford
Date: Tue Apr  6 20:09:46 2010
New Revision: 931301

URL: http://svn.apache.org/viewvc?rev=931301&view=rev
Log:
TRINIDAD-1657 Client date time converter does not properly handle quote escaping

Modified:
    myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js

Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?rev=931301&r1=931300&r2=931301&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js Tue Apr  6 20:09:46 2010
@@ -79,6 +79,7 @@ function _doClumping(
   var kindCount    = 0;
   var lastChar     = void 0;
   var startIndex   = 0;
+  var quoteIndex = null;
   
   for (var i = 0; i < formatLength; i++)
   {
@@ -88,11 +89,17 @@ function _doClumping(
     {
       if (currChar == "\'")
       {
+        // test strings to test escaping working properly
+        // "'one '' two '' three''' 'four '' five'"   ->     "one ' two ' three' four ' five
+        // "HH:mm:ss 'o''clock' z"                    ->     "[time] o'clock [timezone]"
+        // "HH:mm:ss 'oclock' z"                      ->     "[time] oclock [timezone]"
+        // "HH:mm:ss '' z"                            ->     "[time] ' [timezone]"
+        
         inQuote = false;
         
         // handle to single quotes in a row as escaping the quote
         // by not skipping it when outputting
-        if (kindCount != 1)
+        if (kindCount != 1 && startIndex != quoteIndex)
         {
           startIndex++;
           kindCount--;
@@ -111,9 +118,21 @@ function _doClumping(
           // alert("failure at " + startIndex + " with " + lastChar);
           return false;
         }
+               
+        var nextIndex = i + 1;
+    
+        if (nextIndex < formatLength)
+        {
+          var nextChar = formatPattern.charAt(nextIndex);
+          
+          if (nextChar == "\'")
+          {
+            quoteIndex = nextIndex;
+          }
+        } 
         
         kindCount = 0;
-        lastChar  = void 0;
+        lastChar  = void 0; 
       }
       else
       {