Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ScanLiteralAsync()

async Task< Token > System.Xml.DtdParser.ScanLiteralAsync ( LiteralType literalType)
inlineprivate

Definition at line 4791 of file DtdParser.cs.

4792 {
4793 char quoteChar = _chars[_curPos];
4794 char replaceChar = ((literalType == LiteralType.AttributeValue) ? ' ' : '\n');
4797 _curPos++;
4800 while (true)
4801 {
4802 if (XmlCharType.IsAttributeValueChar(_chars[_curPos]) && _chars[_curPos] != '%')
4803 {
4804 _curPos++;
4805 continue;
4806 }
4807 if (_chars[_curPos] == quoteChar && _currentEntityId == startQuoteEntityId)
4808 {
4809 break;
4810 }
4811 int num = _curPos - _tokenStartPos;
4812 if (num > 0)
4813 {
4816 }
4817 switch (_chars[_curPos])
4818 {
4819 case '"':
4820 case '\'':
4821 case '>':
4822 _curPos++;
4823 continue;
4824 case '\n':
4825 _curPos++;
4826 if (Normalize)
4827 {
4830 }
4832 continue;
4833 case '\r':
4834 if (_chars[_curPos + 1] == '\n')
4835 {
4836 if (Normalize)
4837 {
4838 if (literalType == LiteralType.AttributeValue)
4839 {
4841 }
4842 else
4843 {
4845 }
4846 _tokenStartPos = _curPos + 2;
4849 }
4850 _curPos += 2;
4851 }
4852 else
4853 {
4854 if (_curPos + 1 == _charsUsed)
4855 {
4856 break;
4857 }
4858 _curPos++;
4859 if (Normalize)
4860 {
4863 }
4864 }
4866 continue;
4867 case '\t':
4868 if (literalType == LiteralType.AttributeValue && Normalize)
4869 {
4872 }
4873 _curPos++;
4874 continue;
4875 case '<':
4876 if (literalType == LiteralType.AttributeValue)
4877 {
4878 Throw(_curPos, System.SR.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs('<', '\0'));
4879 }
4880 _curPos++;
4881 continue;
4882 case '%':
4883 if (literalType != LiteralType.EntityReplText)
4884 {
4885 _curPos++;
4886 continue;
4887 }
4890 continue;
4891 case '&':
4892 {
4893 if (literalType == LiteralType.SystemOrPublicID)
4894 {
4895 _curPos++;
4896 continue;
4897 }
4898 if (_curPos + 1 == _charsUsed)
4899 {
4900 break;
4901 }
4902 if (_chars[_curPos + 1] == '#')
4903 {
4910 _curPos = num2;
4911 continue;
4912 }
4914 if (literalType == LiteralType.AttributeValue)
4915 {
4918 if (num3 >= 0)
4919 {
4923 _curPos = num3;
4924 }
4925 else
4926 {
4929 }
4930 continue;
4931 }
4934 if (num4 >= 0)
4935 {
4937 _curPos = num4;
4938 continue;
4939 }
4941 _curPos++;
4943 XmlQualifiedName entityName = ScanEntityName();
4945 continue;
4946 }
4947 default:
4948 {
4949 if (_curPos == _charsUsed)
4950 {
4951 break;
4952 }
4953 char ch = _chars[_curPos];
4954 if (XmlCharType.IsHighSurrogate(ch))
4955 {
4956 if (_curPos + 1 == _charsUsed)
4957 {
4958 break;
4959 }
4960 _curPos++;
4961 if (XmlCharType.IsLowSurrogate(_chars[_curPos]))
4962 {
4963 _curPos++;
4964 continue;
4965 }
4966 }
4968 return Token.None;
4969 }
4970 }
4971 bool isEof = _readerAdapter.IsEof;
4972 bool flag = isEof;
4973 if (!flag)
4974 {
4975 flag = await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0;
4976 }
4977 if (flag && (literalType == LiteralType.SystemOrPublicID || !HandleEntityEnd(inLiteral: true)))
4978 {
4980 }
4982 }
4983 if (_stringBuilder.Length > 0)
4984 {
4986 }
4987 _curPos++;
4988 _literalQuoteChar = quoteChar;
4989 return Token.Literal;
4990 }
static string Xml_BadAttributeChar
Definition SR.cs:74
static string Xml_UnclosedQuote
Definition SR.cs:34
Definition SR.cs:7
StringBuilder Append(char value, int repeatCount)
async Task< int > ReadDataAsync()
void Throw(int curPos, string res)
XmlQualifiedName ScanEntityName()
bool HandleEntityEnd(bool inLiteral)
LineInfo _literalLineInfo
Definition DtdParser.cs:192
SchemaEntity VerifyEntityReference(XmlQualifiedName entityName, bool paramEntity, bool mustBeDeclared, bool inAttribute)
IDtdParserAdapter _readerAdapter
Definition DtdParser.cs:140
StringBuilder _internalSubsetValueSb
Definition DtdParser.cs:178
Task< bool > HandleEntityReferenceAsync(bool paramEntity, bool inLiteral, bool inAttribute)
void ThrowInvalidChar(int pos, string data, int invCharPos)
StringBuilder _stringBuilder
Definition DtdParser.cs:188
Task< int > ParseNumericCharRefAsync(StringBuilder internalSubsetBuilder)
Task< int > ParseNamedCharRefAsync(bool expand, StringBuilder internalSubsetBuilder)
void Set(int lineNo, int linePos)
Definition LineInfo.cs:15

References System.Xml.DtdParser._chars, System.Xml.DtdParser._charsUsed, System.Xml.DtdParser._curPos, System.Xml.DtdParser._currentEntityId, System.Xml.DtdParser._internalSubsetValueSb, System.Xml.DtdParser._literalLineInfo, System.Xml.DtdParser._literalQuoteChar, System.Xml.DtdParser._readerAdapter, System.Xml.DtdParser._stringBuilder, System.Xml.DtdParser._tokenStartPos, System.Text.StringBuilder.Append(), System.Xml.XmlException.BuildCharExceptionArgs(), System.ch, System.Xml.IDtdParserAdapter.CurrentPosition, System.Xml.Dictionary, System.Xml.DtdParser.HandleEntityEnd(), System.Xml.DtdParser.HandleEntityReferenceAsync(), System.Xml.XmlCharType.IsAttributeValueChar(), System.Xml.IDtdParserAdapter.IsEntityEolNormalized, System.Xml.IDtdParserAdapter.IsEof, System.Xml.XmlCharType.IsHighSurrogate(), System.Xml.XmlCharType.IsLowSurrogate(), System.Text.StringBuilder.Length, System.Xml.DtdParser.LineNo, System.Xml.DtdParser.LinePos, System.Xml.DtdParser.LoadParsingBuffer(), System.Xml.DtdParser.Normalize, System.Xml.IDtdParserAdapter.OnNewLine(), System.Xml.IDtdParserAdapter.ParseNamedCharRefAsync(), System.Xml.IDtdParserAdapter.ParseNumericCharRefAsync(), System.Xml.DtdParser.ReadDataAsync(), System.Xml.DtdParser.SaveInternalSubsetValue, System.Xml.DtdParser.SaveParsingBuffer(), System.Xml.DtdParser.ScanEntityName(), System.Xml.LineInfo.Set(), System.Xml.DtdParser.Throw(), System.Xml.DtdParser.ThrowInvalidChar(), System.Xml.DtdParser.VerifyEntityReference(), System.SR.Xml_BadAttributeChar, and System.SR.Xml_UnclosedQuote.

Referenced by System.Xml.DtdParser.ScanAttlist6Async(), System.Xml.DtdParser.ScanEntity2Async(), System.Xml.DtdParser.ScanPublicId1Async(), System.Xml.DtdParser.ScanPublicId2Async(), and System.Xml.DtdParser.ScanSystemIdAsync().