private Block BadUrl(char current) { while (true) { if (current == Specification.EndOfFile) { ErrorHandler(ParserError.EndOfFile, ErrorMessages.InvalidUrlEnd); return(StringBlock.Url(FlushBuffer(), true)); } if (current == Specification.ParenClose) { return(StringBlock.Url(FlushBuffer(), true)); } if (IsValidEscape(current)) { current = _stylesheetReader.Next; _buffer.Append(ConsumeEscape(current)); } current = _stylesheetReader.Next; } }
private Block UrlStart(char current) { while (current.IsSpaceCharacter()) { current = _stylesheetReader.Next; } switch (current) { case Specification.EndOfFile: ErrorHandler(ParserError.EndOfFile, ErrorMessages.InvalidUrlEnd); return(StringBlock.Url(string.Empty, true)); case Specification.DoubleQuote: return(DoubleQuotedUrl(_stylesheetReader.Next)); case Specification.SingleQuote: return(SingleQuoteUrl(_stylesheetReader.Next)); case ')': return(StringBlock.Url(string.Empty)); default: return(UnquotedUrl(current)); } }
private Block SingleQuoteUrl(char current) { while (true) { if (current.IsLineBreak()) { ErrorHandler(ParserError.UnexpectedLineBreak, ErrorMessages.SingleQuotedString); return(BadUrl(_stylesheetReader.Next)); } if (Specification.EndOfFile == current) { return(StringBlock.Url(FlushBuffer())); } if (current == Specification.SingleQuote) { return(UrlEnd(_stylesheetReader.Next)); } if (current == Specification.ReverseSolidus) { current = _stylesheetReader.Next; if (current == Specification.EndOfFile) { _stylesheetReader.Back(2); ErrorHandler(ParserError.EndOfFile, ErrorMessages.SingleQuotedString); return(StringBlock.Url(FlushBuffer(), true)); } if (current.IsLineBreak()) { _buffer.AppendLine(); } else { _buffer.Append(ConsumeEscape(current)); } } else { _buffer.Append(current); } current = _stylesheetReader.Next; } }
private Block UrlEnd(char current) { while (true) { if (current == Specification.ParenClose) { return(StringBlock.Url(FlushBuffer())); } if (!current.IsSpaceCharacter()) { ErrorHandler(ParserError.InvalidCharacter, ErrorMessages.InvalidUrlCharacter); return(BadUrl(current)); } current = _stylesheetReader.Next; } }
private Block UnquotedUrl(char current) { while (true) { if (current.IsSpaceCharacter()) { return(UrlEnd(_stylesheetReader.Next)); } if (current == Specification.ParenClose || current == Specification.EndOfFile) { return(StringBlock.Url(FlushBuffer())); } if (current == Specification.DoubleQuote || current == Specification.SingleQuote || current == Specification.ParenOpen || current.IsNonPrintable()) { ErrorHandler(ParserError.InvalidCharacter, ErrorMessages.InvalidUrlQuote); return(BadUrl(_stylesheetReader.Next)); } if (current == Specification.ReverseSolidus) { if (IsValidEscape(current)) { current = _stylesheetReader.Next; _buffer.Append(ConsumeEscape(current)); } else { ErrorHandler(ParserError.InvalidCharacter, ErrorMessages.InvalidUrlCharacter); return(BadUrl(_stylesheetReader.Next)); } } else { _buffer.Append(current); } current = _stylesheetReader.Next; } }