summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp11
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp8
-rw-r--r--core/fxcrt/cfx_bytestring.cpp10
-rw-r--r--core/fxcrt/cfx_bytestring.h1
-rw-r--r--core/fxcrt/cfx_bytestring_unittest.cpp11
-rw-r--r--core/fxcrt/cfx_string_c_template.h19
-rw-r--r--core/fxcrt/cfx_widestring.cpp9
-rw-r--r--core/fxcrt/cfx_widestring.h1
-rw-r--r--core/fxcrt/cfx_widestring_unittest.cpp11
-rw-r--r--core/fxcrt/xml/cxml_parser.cpp2
-rw-r--r--core/fxge/cfx_fontmapper.cpp6
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp3
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp3
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp12
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp30
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_measurement.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp15
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp5
21 files changed, 91 insertions, 76 deletions
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index a6c3ba0547..8c8520f0c4 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -130,7 +130,7 @@ bool CPDF_SimpleFont::LoadCommon() {
}
if (m_pFontFile) {
if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+')
- m_BaseFont = m_BaseFont.Mid(8);
+ m_BaseFont = m_BaseFont.Mid(8, m_BaseFont.GetLength() - 8);
} else {
LoadSubstFont();
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index e00dbc54fd..5f571aa8d6 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -619,7 +619,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
if (type != CPDF_StreamParser::Name) {
break;
}
- CFX_ByteString key(m_pSyntax->GetWord().Mid(1));
+ auto word = m_pSyntax->GetWord();
+ CFX_ByteString key(word.Mid(1, word.GetLength() - 1));
auto pObj = m_pSyntax->ReadNextObject(false, false, 0);
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
@@ -1185,7 +1186,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
}
if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") {
CFX_ByteString defname = "Default";
- defname += name.Mid(7);
+ defname += name.Mid(7, name.GetLength() - 7);
CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
if (!pDefObj) {
if (name == "DeviceGray") {
@@ -1522,9 +1523,11 @@ uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData,
case CPDF_StreamParser::Number:
AddNumberParam(syntax.GetWord());
break;
- case CPDF_StreamParser::Name:
- AddNameParam(syntax.GetWord().Mid(1));
+ case CPDF_StreamParser::Name: {
+ auto word = syntax.GetWord();
+ AddNameParam(word.Mid(1, word.GetLength() - 1));
break;
+ }
default:
AddObjectParam(syntax.GetObject());
}
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index eb874b3352..83c1f65587 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -65,15 +65,17 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
if (!pDRFontDict)
return false;
- CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(sFontName.Mid(1));
+ CPDF_Dictionary* pFontDict =
+ pDRFontDict->GetDictFor(sFontName.Mid(1, sFontName.GetLength() - 1));
if (!pFontDict) {
pFontDict = pDoc->NewIndirect<CPDF_Dictionary>();
pFontDict->SetNewFor<CPDF_Name>("Type", "Font");
pFontDict->SetNewFor<CPDF_Name>("Subtype", "Type1");
pFontDict->SetNewFor<CPDF_Name>("BaseFont", "Helvetica");
pFontDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding");
- pDRFontDict->SetNewFor<CPDF_Reference>(sFontName.Mid(1), pDoc,
- pFontDict->GetObjNum());
+ pDRFontDict->SetNewFor<CPDF_Reference>(
+ sFontName.Mid(1, sFontName.GetLength() - 1), pDoc,
+ pFontDict->GetObjNum());
}
CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
if (!pDefFont)
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp
index c88ad51ab3..e7e55de8e3 100644
--- a/core/fxcrt/cfx_bytestring.cpp
+++ b/core/fxcrt/cfx_bytestring.cpp
@@ -121,6 +121,7 @@ static_assert(sizeof(CFX_ByteString) <= sizeof(char*),
"Strings must not require more space than pointers");
CFX_ByteString::CFX_ByteString(const char* pStr, FX_STRSIZE nLen) {
+ ASSERT(nLen >= 0);
if (nLen < 0)
nLen = pStr ? FXSYS_strlen(pStr) : 0;
@@ -129,6 +130,7 @@ CFX_ByteString::CFX_ByteString(const char* pStr, FX_STRSIZE nLen) {
}
CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) {
+ ASSERT(nLen >= 0);
if (nLen > 0) {
m_pData.Reset(
StringData::Create(reinterpret_cast<const char*>(pStr), nLen));
@@ -456,14 +458,8 @@ void CFX_ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) {
m_pData.Swap(pNewData);
}
-CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst) const {
- if (!m_pData)
- return CFX_ByteString();
-
- return Mid(nFirst, m_pData->m_nDataLength - nFirst);
-}
-
CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
+ ASSERT(nCount >= 0);
if (!m_pData)
return CFX_ByteString();
diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h
index abf8ac80c8..519cee39d4 100644
--- a/core/fxcrt/cfx_bytestring.h
+++ b/core/fxcrt/cfx_bytestring.h
@@ -124,7 +124,6 @@ class CFX_ByteString {
char* GetBuffer(FX_STRSIZE len);
void ReleaseBuffer(FX_STRSIZE len = -1);
- CFX_ByteString Mid(FX_STRSIZE first) const;
CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
CFX_ByteString Left(FX_STRSIZE count) const;
CFX_ByteString Right(FX_STRSIZE count) const;
diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/cfx_bytestring_unittest.cpp
index f5d9413b7d..bcf6f7495e 100644
--- a/core/fxcrt/cfx_bytestring_unittest.cpp
+++ b/core/fxcrt/cfx_bytestring_unittest.cpp
@@ -440,10 +440,10 @@ TEST(fxcrt, ByteStringMid) {
CFX_ByteString fred("FRED");
EXPECT_EQ("", fred.Mid(0, 0));
EXPECT_EQ("", fred.Mid(3, 0));
- EXPECT_EQ("FRED", fred.Mid(0));
- EXPECT_EQ("RED", fred.Mid(1));
- EXPECT_EQ("ED", fred.Mid(2));
- EXPECT_EQ("D", fred.Mid(3));
+ EXPECT_EQ("FRED", fred.Mid(0, 4));
+ EXPECT_EQ("RED", fred.Mid(1, 3));
+ EXPECT_EQ("ED", fred.Mid(2, 2));
+ EXPECT_EQ("D", fred.Mid(3, 1));
EXPECT_EQ("F", fred.Mid(0, 1));
EXPECT_EQ("R", fred.Mid(1, 1));
EXPECT_EQ("E", fred.Mid(2, 1));
@@ -458,9 +458,6 @@ TEST(fxcrt, ByteStringMid) {
CFX_ByteString empty;
EXPECT_EQ("", empty.Mid(0, 0));
- EXPECT_EQ("", empty.Mid(0));
- EXPECT_EQ("", empty.Mid(1));
- EXPECT_EQ("", empty.Mid(-1));
}
TEST(fxcrt, ByteStringLeft) {
diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/cfx_string_c_template.h
index cd3cd27e75..77f34f638e 100644
--- a/core/fxcrt/cfx_string_c_template.h
+++ b/core/fxcrt/cfx_string_c_template.h
@@ -130,29 +130,32 @@ class CFX_StringCTemplate {
return found ? found - m_Ptr.Get() : -1;
}
- CFX_StringCTemplate Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
- index = std::max(0, index);
+ CFX_StringCTemplate Mid(FX_STRSIZE index, FX_STRSIZE count) const {
+ ASSERT(count >= 0);
if (index > m_Length)
return CFX_StringCTemplate();
- if (count < 0 || count > m_Length - index)
- count = m_Length - index;
+ index = pdfium::clamp(index, 0, m_Length);
+ count = pdfium::clamp(count, 0, m_Length - index);
+ if (count == 0)
+ return CFX_StringCTemplate();
return CFX_StringCTemplate(m_Ptr.Get() + index, count);
}
CFX_StringCTemplate Left(FX_STRSIZE count) const {
- if (count <= 0)
+ count = pdfium::clamp(count, 0, m_Length);
+ if (count == 0)
return CFX_StringCTemplate();
- return CFX_StringCTemplate(m_Ptr.Get(), std::min(count, m_Length));
+ return CFX_StringCTemplate(m_Ptr.Get(), count);
}
CFX_StringCTemplate Right(FX_STRSIZE count) const {
- if (count <= 0)
+ count = pdfium::clamp(count, 0, m_Length);
+ if (count == 0)
return CFX_StringCTemplate();
- count = std::min(count, m_Length);
return CFX_StringCTemplate(m_Ptr.Get() + m_Length - count, count);
}
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp
index 6a4fbb9846..d7c1ef23ea 100644
--- a/core/fxcrt/cfx_widestring.cpp
+++ b/core/fxcrt/cfx_widestring.cpp
@@ -291,6 +291,7 @@ CFX_WideString::CFX_WideString(CFX_WideString&& other) noexcept {
}
CFX_WideString::CFX_WideString(const wchar_t* pStr, FX_STRSIZE nLen) {
+ ASSERT(nLen >= 0);
if (nLen < 0)
nLen = pStr ? FXSYS_wcslen(pStr) : 0;
@@ -605,14 +606,8 @@ CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
return result;
}
-CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst) const {
- if (!m_pData)
- return CFX_WideString();
-
- return Mid(nFirst, m_pData->m_nDataLength - nFirst);
-}
-
CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
+ ASSERT(nCount >= 0);
if (!m_pData)
return CFX_WideString();
diff --git a/core/fxcrt/cfx_widestring.h b/core/fxcrt/cfx_widestring.h
index 0e477bfc8b..938b1e7958 100644
--- a/core/fxcrt/cfx_widestring.h
+++ b/core/fxcrt/cfx_widestring.h
@@ -112,7 +112,6 @@ class CFX_WideString {
int Compare(const CFX_WideString& str) const;
int CompareNoCase(const wchar_t* str) const;
- CFX_WideString Mid(FX_STRSIZE first) const;
CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
CFX_WideString Left(FX_STRSIZE count) const;
CFX_WideString Right(FX_STRSIZE count) const;
diff --git a/core/fxcrt/cfx_widestring_unittest.cpp b/core/fxcrt/cfx_widestring_unittest.cpp
index 4cd71d9997..1d6d110497 100644
--- a/core/fxcrt/cfx_widestring_unittest.cpp
+++ b/core/fxcrt/cfx_widestring_unittest.cpp
@@ -406,10 +406,10 @@ TEST(fxcrt, WideStringMid) {
CFX_WideString fred(L"FRED");
EXPECT_EQ(L"", fred.Mid(0, 0));
EXPECT_EQ(L"", fred.Mid(3, 0));
- EXPECT_EQ(L"FRED", fred.Mid(0));
- EXPECT_EQ(L"RED", fred.Mid(1));
- EXPECT_EQ(L"ED", fred.Mid(2));
- EXPECT_EQ(L"D", fred.Mid(3));
+ EXPECT_EQ(L"FRED", fred.Mid(0, 4));
+ EXPECT_EQ(L"RED", fred.Mid(1, 3));
+ EXPECT_EQ(L"ED", fred.Mid(2, 2));
+ EXPECT_EQ(L"D", fred.Mid(3, 1));
EXPECT_EQ(L"F", fred.Mid(0, 1));
EXPECT_EQ(L"R", fred.Mid(1, 1));
EXPECT_EQ(L"E", fred.Mid(2, 1));
@@ -424,9 +424,6 @@ TEST(fxcrt, WideStringMid) {
CFX_WideString empty;
EXPECT_EQ(L"", empty.Mid(0, 0));
- EXPECT_EQ(L"", empty.Mid(0));
- EXPECT_EQ(L"", empty.Mid(1));
- EXPECT_EQ(L"", empty.Mid(-1));
}
TEST(fxcrt, WideStringLeft) {
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index a741d8409e..0166ea8490 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -87,7 +87,7 @@ void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
bsName = bsFullName;
} else {
bsSpace = bsFullName.Mid(0, iStart);
- bsName = bsFullName.Mid(iStart + 1);
+ bsName = bsFullName.Mid(iStart + 1, bsFullName.GetLength() - (iStart + 1));
}
}
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index 5b4ceaac59..5c7b602fed 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -432,7 +432,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
CFX_ByteString SubstName = name;
SubstName.Remove(' ');
if (bTrueType && name[0] == '@')
- SubstName = name.Mid(1);
+ SubstName = name.Mid(1, name.GetLength() - 1);
PDF_GetStandardFontName(&SubstName);
if (SubstName == "Symbol" && !bTrueType) {
pSubstFont->m_Family = "Chrome Symbol";
@@ -453,7 +453,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
if (find >= 0) {
family = SubstName.Left(find);
PDF_GetStandardFontName(&family);
- style = SubstName.Mid(find + 1);
+ style = SubstName.Mid(find + 1, SubstName.GetLength() - (find + 1));
bHasComma = true;
} else {
family = SubstName;
@@ -480,7 +480,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
if (!bHasComma) {
find = family.ReverseFind('-');
if (find >= 0) {
- style = family.Mid(find + 1);
+ style = family.Mid(find + 1, family.GetLength() - (find + 1));
family = family.Left(find);
bHasHyphen = true;
}
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index 8bef264085..b195303800 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -220,7 +220,8 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString* sAlias) {
syntax.FindTagParamFromStart("Tf", 2);
CFX_ByteString sFontName(syntax.GetWord());
- *sAlias = PDF_NameDecode(sFontName).Mid(1);
+ CFX_ByteString sDecodedFontName = PDF_NameDecode(sFontName);
+ *sAlias = sDecodedFontName.Mid(1, sDecodedFontName.GetLength() - 1);
CPDF_Dictionary* pFontDict = nullptr;
if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP")) {
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index bdae064cea..bf84b9cd91 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -983,7 +983,8 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime,
CFX_WideString wprefix = wstrValue.Mid(0, pEvent->SelStart());
CFX_WideString wpostfix;
if (pEvent->SelEnd() < wstrValue.GetLength())
- wpostfix = wstrValue.Mid(pEvent->SelEnd());
+ wpostfix = wstrValue.Mid(pEvent->SelEnd(),
+ wstrValue.GetLength() - pEvent->SelEnd());
val = wprefix + wstrChange + wpostfix;
return true;
}
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 445d729668..1910e60e3e 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -1138,7 +1138,8 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
CXFA_Document* pDoc = pContext->GetDocument();
CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
CFX_ByteString szArgString = ValueToUTF8String(argOne.get());
- szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1);
+ FX_STRSIZE pos = szArgString.Find('T', 0);
+ szArgString = szArgString.Mid(pos + 1, szArgString.GetLength() - (pos + 1));
if (szArgString.IsEmpty()) {
args.GetReturnValue()->SetInteger(0);
return;
@@ -3692,7 +3693,9 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
wsDatePattern += wsPattern.Left(iTChar) + L"} ";
CFX_WideString wsTimePattern(L"time{");
- wsTimePattern += wsPattern.Mid(iTChar + 1) + L"}";
+ wsTimePattern +=
+ wsPattern.Mid(iTChar + 1, wsPattern.GetLength() - (iTChar + 1)) +
+ L"}";
wsPattern = wsDatePattern + wsTimePattern;
} break;
case XFA_VT_DATE: {
@@ -3877,7 +3880,10 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
case XFA_VT_DATETIME: {
FX_STRSIZE iTChar = wsPattern.Find(L'T');
CFX_WideString wsDatePattern(L"date{" + wsPattern.Left(iTChar) + L"} ");
- CFX_WideString wsTimePattern(L"time{" + wsPattern.Mid(iTChar + 1) + L"}");
+ CFX_WideString wsTimePattern(
+ L"time{" +
+ wsPattern.Mid(iTChar + 1, wsPattern.GetLength() - (iTChar + 1)) +
+ L"}");
wsPattern = wsDatePattern + wsTimePattern;
CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale,
pMgr);
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index 7e6e0954aa..b201863b25 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -61,7 +61,8 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
}
javascript << L"function ";
if (m_wsName.GetAt(0) == L'!') {
- CFX_WideString tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1);
+ CFX_WideString tempName =
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
javascript << tempName;
} else {
javascript << m_wsName;
@@ -73,7 +74,8 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L", ";
if (identifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
- EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1);
+ EXCLAMATION_IN_IDENTIFIER +
+ identifier.Mid(1, identifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << identifier;
@@ -127,7 +129,8 @@ bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"var ";
CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
- tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1);
+ tempName =
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
}
javascript << tempName;
javascript << L" = ";
@@ -150,7 +153,8 @@ bool CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << L"var ";
CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
- tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1);
+ tempName =
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
}
javascript << tempName;
javascript << L" = ";
@@ -456,7 +460,8 @@ bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"{\nvar ";
CFX_WideString tempVariant;
if (m_wsVariant.GetAt(0) == L'!') {
- tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Mid(1);
+ tempVariant = EXCLAMATION_IN_IDENTIFIER +
+ m_wsVariant.Mid(1, m_wsVariant.GetLength() - 1);
javascript << tempVariant;
} else {
tempVariant = m_wsVariant;
@@ -510,7 +515,8 @@ bool CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << L"{\nvar ";
CFX_WideString tempVariant;
if (m_wsVariant.GetAt(0) == L'!') {
- tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Mid(1);
+ tempVariant = EXCLAMATION_IN_IDENTIFIER +
+ m_wsVariant.Mid(1, m_wsVariant.GetLength() - 1);
javascript << tempVariant;
} else {
tempVariant = m_wsVariant;
@@ -576,7 +582,8 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"var ";
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
- EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1);
+ EXCLAMATION_IN_IDENTIFIER +
+ m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -607,7 +614,8 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L".length)\n{\n";
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
- EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1);
+ EXCLAMATION_IN_IDENTIFIER +
+ m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -631,7 +639,8 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << L"var ";
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
- EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1);
+ EXCLAMATION_IN_IDENTIFIER +
+ m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -661,7 +670,8 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << L".length)\n{\n";
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
- EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Mid(1);
+ EXCLAMATION_IN_IDENTIFIER +
+ m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index 955b06fe93..1a3a125032 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -180,7 +180,8 @@ bool CXFA_FMIdentifierExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
} else if (tempStr == L"$template") {
tempStr = L"xfa.template";
} else if (tempStr[0] == L'!') {
- tempStr = EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1);
+ tempStr =
+ EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1, tempStr.GetLength() - 1);
}
javascript << tempStr;
return true;
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index a3f4ce9519..e3565835c3 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -162,7 +162,7 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
if (wsExpr.GetAt(0) == '#') {
CXFA_Node* pNode = pDocument->GetNodeByID(
ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)),
- wsExpr.Mid(1).AsStringC());
+ wsExpr.Mid(1, wsExpr.GetLength() - 1).AsStringC());
if (pNode)
return pNode;
} else if (bNewExprStyle) {
diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp
index f161e49e49..50076583bb 100644
--- a/xfa/fxfa/parser/cxfa_measurement.cpp
+++ b/xfa/fxfa/parser/cxfa_measurement.cpp
@@ -40,7 +40,8 @@ void CXFA_Measurement::SetString(const CFX_WideStringC& wsMeasure) {
int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0;
float fValue = FXSYS_wcstof(wsMeasure.unterminated_c_str() + iOffset,
wsMeasure.GetLength() - iOffset, &iUsedLen);
- XFA_UNIT eUnit = GetUnitFromString(wsMeasure.Mid(iOffset + iUsedLen));
+ XFA_UNIT eUnit = GetUnitFromString(wsMeasure.Mid(
+ iOffset + iUsedLen, wsMeasure.GetLength() - (iOffset + iUsedLen)));
Set(fValue, eUnit);
}
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index eac7ac04b0..1265988902 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -77,7 +77,7 @@ int32_t GetCount(CXFA_Node* pInstMgrNode) {
CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' ||
- wsInstName.Mid(1) != wsName) {
+ wsInstName.Mid(1, wsInstName.GetLength() - 1) != wsName) {
return iCount;
}
dwNameHash = pNode->GetNameHash();
@@ -198,7 +198,7 @@ CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) {
CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' ||
- wsInstName.Mid(1) != wsName) {
+ wsInstName.Mid(1, wsInstName.GetLength() - 1) != wsName) {
return nullptr;
}
dwNameHash = pNode->GetNameHash();
@@ -2737,7 +2737,7 @@ void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue,
if (pNode->GetElementType() == XFA_Element::InstanceManager) {
CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' &&
- wsInstMgrName.Mid(1) == wsName) {
+ wsInstMgrName.Mid(1, wsInstMgrName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
}
break;
@@ -3162,9 +3162,10 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
}
if (iDesired < iCount) {
CFX_WideStringC wsInstManagerName = GetCData(XFA_ATTRIBUTE_Name);
- CFX_WideString wsInstanceName =
- CFX_WideString(wsInstManagerName.IsEmpty() ? wsInstManagerName
- : wsInstManagerName.Mid(1));
+ CFX_WideString wsInstanceName = CFX_WideString(
+ wsInstManagerName.IsEmpty()
+ ? wsInstManagerName
+ : wsInstManagerName.Mid(1, wsInstManagerName.GetLength() - 1));
uint32_t dInstanceNameHash =
FX_HashCode_GetW(wsInstanceName.AsStringC(), false);
CXFA_Node* pPrevSibling =
@@ -4664,7 +4665,7 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() {
CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' &&
- wsInstName.Mid(1) == wsName) {
+ wsInstName.Mid(1, wsInstName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
}
break;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index cbe0d14c91..1920e9f3fd 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1323,7 +1323,10 @@ bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
} else {
int32_t fA, fB;
fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos).c_str());
- fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1).c_str());
+ fB = FXSYS_wtoi(
+ wsWideNarrowRatio
+ .Mid(ptPos + 1, wsWideNarrowRatio.GetLength() - (ptPos + 1))
+ .c_str());
if (fB)
fRatio = (float)fA / fB;
}