Commit 8ec54754 by Matt Mascarenhas

cinera.c: Fail earlier on unknown project

HTML-santitise episode title and project name from templates. This won't always be correct, but I reckon the common case will require it.
parent c788fd46
......@@ -16,7 +16,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 5,
.Patch = 52
.Patch = 53
};
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
......@@ -4343,7 +4343,7 @@ AppendedIdentifier:
}
CollationBuffers->IncludesPlayer.Ptr -= 2;
CopyStringToBuffer(&CollationBuffers->IncludesPlayer, "\">\n\n");
CopyStringToBuffer(&CollationBuffers->IncludesPlayer, "\">\n");
}
ConstructURLPrefix(&URLPrefix, INCLUDE_CSS, PAGE_PLAYER);
......@@ -4451,11 +4451,11 @@ BuffersToHTML(buffers *CollationBuffers, template *Template, char *OutputPath, i
}
else
{
CopyStringToBufferNoFormat(&Output, CollationBuffers->ProjectName);
CopyStringToBufferHTMLSafe(&Output, CollationBuffers->ProjectName);
}
break;
case TAG_TITLE:
CopyStringToBufferNoFormat(&Output, CollationBuffers->Title);
CopyStringToBufferHTMLSafe(&Output, CollationBuffers->Title);
break;
case TAG_URL:
if(PageType == PAGE_PLAYER)
......@@ -5454,23 +5454,15 @@ IndexToBuffer(index *Index, buffers *CollationBuffers) // NOTE(matt): This guy m
{
Index->Header = *(index_header*)Index->Metadata.Buffer.Location;
bool ProjectFound = FALSE;
int ProjectIndex;
for(ProjectIndex = 0; ProjectIndex < ArrayCount(ProjectInfo); ++ProjectIndex)
{
if(!StringsDiffer(ProjectInfo[ProjectIndex].ProjectID, Config.ProjectID))
{
ProjectFound = TRUE;
break;
}
}
if(!ProjectFound)
{
fprintf(stderr, "Missing Project Info for %s\n", Config.ProjectID);
return RC_ERROR_PROJECT;
}
char *Theme = StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID;
int Allowance = StringLength(Theme) * 2 + StringLength(Config.ProjectID) + StringLength(Config.BaseURL) + StringLength(Config.PlayerLocation);
char queryContainer[656 + Allowance]; // NOTE(matt): Update the size if changing the string
......@@ -6421,11 +6413,12 @@ main(int ArgC, char **Args)
}
Config.Edition = EDITION_PROJECT;
bool KnownProject = FALSE;
for(int ProjectInfoIndex = 0; ProjectInfoIndex < ArrayCount(ProjectInfo); ++ProjectInfoIndex)
{
if(!StringsDiffer(Config.ProjectID, ProjectInfo[ProjectInfoIndex].ProjectID))
{
KnownProject = TRUE;
if(StringsDiffer(ProjectInfo[ProjectInfoIndex].Medium, ""))
{
Config.DefaultMedium = ProjectInfo[ProjectInfoIndex].Medium;
......@@ -6453,6 +6446,11 @@ main(int ArgC, char **Args)
break;
}
}
if(!KnownProject)
{
fprintf(stderr, "\e[1;31mMissing Project Info for %s\e[0m \e[1;30m(-p)\e[0m\n", Config.ProjectID);
HaveConfigErrors = TRUE;
}
}
if(StringsDiffer(Config.BaseURL, "") && StringLength(Config.BaseURL) > MAX_BASE_URL_LENGTH)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment