cinera.c: Handle overlong "output" attribute

This commit is contained in:
Matt Mascarenhas 2022-08-03 22:56:24 +01:00
parent 84a35b9ece
commit e17c3aa78c
1 changed files with 22 additions and 17 deletions

View File

@ -23,7 +23,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 10,
.Patch = 8
.Patch = 9
};
#include <stdarg.h> // NOTE(matt): varargs
@ -10259,12 +10259,6 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
CollationBuffers->VODPlatform = VODPlatform;
}
buffer URLPlayer = {};
ClaimBuffer(&URLPlayer, BID_URL_PLAYER, MAX_BASE_URL_LENGTH + 1 + MAX_RELATIVE_PAGE_LOCATION_LENGTH + 1 + MAX_BASE_FILENAME_LENGTH);
ConstructPlayerURL(&URLPlayer, N->Project, HMML.metadata.output ? Wrap0(HMML.metadata.output) : BaseFilename);
CopyString(CollationBuffers->URLPlayer, sizeof(CollationBuffers->URLPlayer), "%s", URLPlayer.Location);
DeclaimBuffer(&URLPlayer);
medium *DefaultMedium = CurrentProject->DefaultMedium;
if(HMML.metadata.medium)
{
@ -10301,6 +10295,21 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
ClearCopyStringNoFormat(N->WorkingThis.Number, sizeof(N->WorkingThis.Number), Wrap0(HMML.metadata.number));
}
string OutputLocation = {};
if(!HMML.metadata.output)
{
OutputLocation = BaseFilename;
}
else if(StringLength(HMML.metadata.output) > sizeof(N->WorkingThis.OutputLocation))
{
IndexingErrorSizing(&FilepathL, 0, "output", Wrap0(HMML.metadata.output), MAX_ENTRY_OUTPUT_LENGTH);
Result = RC_ERROR_HMML;
}
else
{
OutputLocation = Wrap0(HMML.metadata.output);
}
string ProjectTitle = BestTitleForHTML(CurrentProject);
// TODO(matt): Handle the art and art_variants once .hmml supports them
@ -10352,18 +10361,14 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
if(Result == RC_SUCCESS)
{
string OutputLocation = {};
if(HMML.metadata.output)
{
OutputLocation = Wrap0(HMML.metadata.output);
}
else
{
OutputLocation = BaseFilename;
}
ClearCopyStringNoFormat(N->WorkingThis.OutputLocation, sizeof(N->WorkingThis.OutputLocation), OutputLocation);
buffer URLPlayer = {};
ClaimBuffer(&URLPlayer, BID_URL_PLAYER, MAX_BASE_URL_LENGTH + SLASH + MAX_RELATIVE_PAGE_LOCATION_LENGTH + SLASH + sizeof(N->WorkingThis.OutputLocation));
ConstructPlayerURL(&URLPlayer, N->Project, Wrap0i(N->WorkingThis.OutputLocation, sizeof(N->WorkingThis.OutputLocation)));
CopyString(CollationBuffers->URLPlayer, sizeof(CollationBuffers->URLPlayer), "%s", URLPlayer.Location);
DeclaimBuffer(&URLPlayer);
if(N->This)
{
string OldOutputLocation = Wrap0i(N->This->OutputLocation, sizeof(N->This->OutputLocation));