Enable test for formcalc eval().

Then fix the bug in formcalc translation where we were appending
an extraneous NUL onto the end of a WideTextBuf. WideTextBuf's
methods give perfectly valid strings or string views based upon
the accumulated length, so this additional NUL was being passed
into JavaScript as part of an expression.  The expression then
failed to parse when the NUL was seen, giving an invalid token
error.

- Remove several other occurrences of the same pattern.

Change-Id: I4bb68e573c9e41ecb5eca73b009ce8876238997e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69090
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 507b9fe..ad46ec1 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -890,7 +890,6 @@
     }
     wsResultBuf.AppendChar(chTemp);
   }
-  wsResultBuf.AppendChar(0);
   return wsResultBuf.MakeString();
 }
 
@@ -958,8 +957,6 @@
         wsResultBuf.AppendChar('>');
     }
   }
-
-  wsResultBuf.AppendChar(0);
   return wsResultBuf.MakeString();
 }
 
@@ -1065,7 +1062,6 @@
       }
     }
   }
-  wsResultBuf.AppendChar(0);
   return wsResultBuf.MakeString();
 }
 
@@ -1105,7 +1101,6 @@
       // TODO(tsepez): Handle codepoint not in BMP.
     }
   }
-  wsResultBuf.AppendChar(0);
   return wsResultBuf.MakeString();
 }
 
@@ -1170,7 +1165,6 @@
       }
     }
   }
-  wsResultBuf.AppendChar(0);
   return wsResultBuf.MakeString();
 }
 
@@ -3838,8 +3832,6 @@
       ch += 1;
     szLowBuf.AppendChar(ch);
   }
-  szLowBuf.AppendChar(0);
-
   auto result = FX_UTF8Encode(szLowBuf.AsStringView());
   info.GetReturnValue().Set(
       fxv8::NewStringHelper(info.GetIsolate(), result.AsStringView()));
@@ -4373,8 +4365,6 @@
     upperStringBuf.AppendChar(ch);
     ++i;
   }
-  upperStringBuf.AppendChar(0);
-
   info.GetReturnValue().Set(fxv8::NewStringHelper(
       info.GetIsolate(),
       FX_UTF8Encode(upperStringBuf.AsStringView()).AsStringView()));
@@ -5681,7 +5671,6 @@
   if (!ast->ToJavaScript(wsJavascript))
     return false;
 
-  wsJavascript->AppendChar(0);
   return !CXFA_IsTooBig(wsJavascript);
 }
 
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
index 7ac25c0..17fc228 100644
--- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -907,7 +907,7 @@
   }
 }
 
-TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Eval) {
+TEST_F(CFXJSE_FormCalcContextEmbedderTest, Eval) {
   ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
 
   struct {