Skip to content

Commit

Permalink
Remove cross repo links before processing markdown file (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
millicentachieng authored Oct 13, 2023
1 parent 74fefa7 commit cb6e353
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ApiDoctor.Validation/Tags/TagProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class TagProcessor

private static Regex ValidTagFormat = new Regex(@"^\[TAGS=[-\.\w]+(?:,\s?[-\.\w]*)*\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static Regex GetTagList = new Regex(@"\[TAGS=([-\.,\s\w]+)\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static Regex IncludeFormat = new Regex(@"\[!INCLUDE\s*\[[-/.\w]+\]\(([-/.\w]+)\)\s*\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static Regex IncludeFormat = new Regex(@"\[!INCLUDE\s*\[[-/.\w~]+\]\(([-/.\w~]+)\)\s*\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static Regex AlertFormat = new Regex(@"\[(!NOTE|!TIP|!IMPORTANT|!CAUTION|!WARNING)\s*\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static Regex DivFormat = new Regex(@"\[(!div (([\w]*=""[\w]*"")\s*)*)\s*\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static Regex VideoFormat = new Regex(@"\[!VIDEO ((https]?):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Expand Down Expand Up @@ -166,6 +166,13 @@ public string Preprocess(FileInfo sourceFile, IssueLogger issues)
// Import include file content
if (IsIncludeLine(nextLine))
{
// if contains tilde, then file is not in current docset and cannot be validated
if (nextLine.Contains("~"))
{
LogMessage(new ValidationError(ValidationErrorCode.MarkdownParserError, nextLine, "Cannot validate INCLUDE links referencing content outside of doc set"));
continue;
}

var includeFile = GetIncludeFile(nextLine, sourceFile);
if (!includeFile.Exists)
{
Expand Down

0 comments on commit cb6e353

Please sign in to comment.