diff --git a/api/ECNQueue.py b/api/ECNQueue.py index 2cfcf98..cb5cd41 100644 --- a/api/ECNQueue.py +++ b/api/ECNQueue.py @@ -212,7 +212,7 @@ def __parseHeaders(self) -> list: # Example: # [ce] QTime-Updated-By: campb303 becomes # QTime-Updated-By: campb303 - queuePrefixPattern = re.compile("\[.*\] {1}") + queuePrefixPattern = re.compile(r"\[.*?\] {1}") for lineNumber in range(self.__getHeaderBoundary()): line = self.__rawItem[lineNumber] lineHasQueuePrefix = queuePrefixPattern.match(line) @@ -263,6 +263,12 @@ def __parseSections(self) -> list: for assignment in assignementLsit: sections.append(assignment) + # Checks for empty content within an item and returns and + if contentEnd <= contentStart: + blankInitialMessage = self.__initialMessageParsing([""]) + sections.append(blankInitialMessage) + return sections + # Checks for Directory Identifiers if self.__rawItem[contentStart] == "\n" and self.__rawItem[contentStart + 1].startswith("\t"): @@ -915,6 +921,10 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: if line == "\n": newLineCounter = newLineCounter + 1 + if newLineCounter == 2 and "datetime" not in replyFromInfo.keys(): + errorMessage = "Expected \"Date: [datetime]\" in the header info" + return self.__errorParsing(line, lineNumber + lineNum + 1, errorMessage) + elif line == "===============================================\n": endingDelimiterCount = endingDelimiterCount + 1 @@ -1190,7 +1200,19 @@ def __getUserAlias(self) -> str: Returns: str: User's Career Account alias if present or empty string """ - emailUser, emailDomain = self.userEmail.split("@") + + + try: + emailUser, emailDomain = self.userEmail.split("@") + + # Returns an error parse if the self.useremail doesn't contain exactally one "@" symbol + except ValueError: + # Parses through the self.headers list to find the "From" header and its line number + for lineNum, header in enumerate(self.headers): + if header["type"] == "From": + headerString = header["type"] + ": " + header["content"] + return self.__errorParsing(headerString, lineNum + 1, "Expected valid email Address") + return emailUser if emailDomain.endswith("purdue.edu") else "" def __getFormattedDate(self, date: str) -> str: