for (size_t i = 0; i < length; i++)
{
sal_Unicode c = rRawString[i];
if (c == '=')
{ if (! bInValue)
{
sType = rRawString.substr(nTypeNameStart, i - nTypeNameStart);
sType = o3tl::trim(sType);
bInType = false;
} else
{
sbufValue.append(c);
}
} elseif (c == '"')
{ if (!bInEscape)
{ //If this is the quote is the first of the couple which enclose the //whole value, because the value contains special characters //then we just drop it. That is, this character must be followed by //a character which is not '"'. if ( i + 1 < length && rRawString[i+1] == '"')
bInEscape = true; else
bInValue = !bInValue; //value is enclosed in " "
} else
{ //This quote is escaped by a preceding quote and therefore is //part of the value
sbufValue.append(c);
bInEscape = false;
}
} elseif (c == ',' || c == '+')
{ //The comma separate the attribute value pairs. //If the comma is not part of a value (the value would then be enclosed in '"'), //then we have reached the end of the value if (!bInValue)
{
OSL_ASSERT(!sType.empty());
retVal.emplace_back(OUString(sType), sbufValue.makeStringAndClear());
sType = {}; //The next char is the start of the new type
nTypeNameStart = i + 1;
bInType = true;
} else
{ //The whole string is enclosed because it contains special characters. //The enclosing '"' are not part of certificate but will be added by //the function (Windows or NSS) which retrieves DN
sbufValue.append(c);
}
} else
{ if (!bInType)
sbufValue.append(c);
}
} if (sbufValue.getLength())
{
OSL_ASSERT(!sType.empty());
retVal.emplace_back(OUString(sType), sbufValue.makeStringAndClear());
} return retVal;
} #else
std::vector< std::pair< OUString, OUString> > parseDN(std::u16string_view rRawString)
{
std::vector< std::pair<OUString, OUString> > retVal; //bInEscape == true means that the preceding character is an escape character bool bInEscape = false; bool bInValue = false; bool bInType = true;
sal_Int32 nTypeNameStart = 0;
std::u16string_view sType;
OUStringBuffer sbufValue;
size_t length = rRawString.size();
for (size_t i = 0; i < length; i++)
{
sal_Unicode c = rRawString[i];
if (c == '=')
{ if (! bInValue)
{
sType = rRawString.substr(nTypeNameStart, i - nTypeNameStart);
sType = o3tl::trim(sType);
bInType = false;
} else
{
sbufValue.append(c);
}
} elseif (c == '\\')
{ if (!bInEscape)
{
bInEscape = true;
} else
{ // bInEscape is true
sbufValue.append(c);
bInEscape = false;
}
} elseif (c == '"')
{ //an unescaped '"' is either at the beginning or end of the value if (!bInEscape)
{ if ( !bInValue)
bInValue = true; elseif (bInValue)
bInValue = false;
} else
{ //This quote is escaped by a preceding quote and therefore is //part of the value
sbufValue.append(c);
bInEscape = false;
}
} elseif (c == ',' || c == '+')
{ //The comma separate the attribute value pairs. //If the comma is not part of a value (the value would then be enclosed in '"'), //then we have reached the end of the value if (!bInValue)
{
OSL_ASSERT(!sType.empty());
retVal.emplace_back(sType, sbufValue.makeStringAndClear());
sType = {}; //The next char is the start of the new type
nTypeNameStart = i + 1;
bInType = true;
} else
{ //The whole string is enclosed because it contains special characters. //The enclosing '"' are not part of certificate but will be added by //the function (Windows or NSS) which retrieves DN
sbufValue.append(c);
}
} else
{ if (!bInType)
{
sbufValue.append(c);
bInEscape = false;
}
}
} if (!sbufValue.isEmpty())
{
OSL_ASSERT(!sType.empty());
retVal.emplace_back(sType, sbufValue.makeStringAndClear());
} return retVal;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.