diff --git a/cinera/cinera.c b/cinera/cinera.c index bd43638..7641918 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -2,6 +2,8 @@ ctime -begin ${0%.*}.ctm #gcc -g -fsanitize=address -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl gcc -O2 -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl +#clang -fsanitize=address -g -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl +#clang -O2 -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl ctime -end ${0%.*}.ctm exit #endif @@ -14,7 +16,7 @@ typedef struct version CINERA_APP_VERSION = { .Major = 0, .Minor = 5, - .Patch = 45 + .Patch = 46 }; // TODO(matt): Copy in the DB 3 stuff from cinera_working.c @@ -529,16 +531,13 @@ project_info ProjectInfo[] = #define ArrayCount(A) sizeof(A)/sizeof(*(A)) -__attribute__ ((format (printf, 2, 3))) -int -CopyString(char Dest[], char *Format, ...) +void +Clear(char *String, int Size) { - int Length = 0; - va_list Args; - va_start(Args, Format); - Length = vsprintf(Dest, Format, Args); - va_end(Args); - return Length; + for(int i = 0; i < Size; ++i) + { + String[i] = 0; + } } int @@ -552,166 +551,223 @@ StringLength(char *String) return i; } -void -CopyBuffer(buffer *Dest, buffer *Src) -{ - Src->Ptr = Src->Location; - while(*Src->Ptr) - { - // TODO(matt) - { - if(Dest->Ptr - Dest->Location >= Dest->Size) - { - fprintf(stderr, "CopyBuffer: %s cannot accommodate %s\n", Dest->ID, Src->ID); - __asm__("int3"); - } - } - *Dest->Ptr++ = *Src->Ptr++; - } - *Dest->Ptr = '\0'; -} - -void -Clear(char *String, int Size) -{ - for(int i = 0; i < Size; ++i) - { - String[i] = 0; - } -} - +#define CopyString(Dest, DestSize, Format, ...) CopyString_(__LINE__, (Dest), (DestSize), (Format), ##__VA_ARGS__) +__attribute__ ((format (printf, 4, 5))) int -CopyStringNoFormat(char *Dest, char *String) +CopyString_(int LineNumber, char Dest[], int DestSize, char *Format, ...) { int Length = 0; + va_list Args; + va_start(Args, Format); + Length = vsnprintf(Dest, DestSize, Format, Args); + if(Length >= DestSize) + { + printf("CopyString() call on line %d has been passed a buffer too small (%d bytes) to contain null-terminated %d(+1)-character string\n", LineNumber, DestSize, Length); + __asm__("int3"); + } + va_end(Args); + return Length; +} + +#define CopyStringNoFormat(Dest, DestSize, String) CopyStringNoFormat_(__LINE__, Dest, DestSize, String) +int +CopyStringNoFormat_(int LineNumber, char *Dest, int DestSize, char *String) +{ + int Length = 0; + char *Start = String; while(*String) { *Dest++ = *String++; ++Length; } + if(Length >= DestSize) + { + printf("CopyStringNoFormat() call on line %d has been passed a buffer too small (%d bytes) to contain null-terminated %d(+1)-character string:\n" + "%s\n", LineNumber, DestSize, Length, Start); + __asm__("int3"); + } *Dest = '\0'; return Length; } +#define ClearCopyStringNoFormat(Dest, DestSize, String) ClearCopyStringNoFormat_(__LINE__, Dest, DestSize, String) int -ClearCopyStringNoFormat(char *Dest, int DestSize, char *String) +ClearCopyStringNoFormat_(int LineNumber, char *Dest, int DestSize, char *String) { Clear(Dest, DestSize); - return(CopyStringNoFormat(Dest, String)); + int Length = 0; + char *Start = String; + while(*String) + { + *Dest++ = *String++; + ++Length; + } + if(Length >= DestSize) + { + printf("ClearCopyStringNoFormat() call on line %d has been passed a buffer too small (%d bytes) to contain null-terminated %d(+1)-character string:\n" + "%s\n", LineNumber, DestSize, Length, Start); + __asm__("int3"); + } + *Dest = '\0'; + return Length; } // TODO(matt): Maybe do a version of this that takes a string as a Terminator +#define CopyStringNoFormatT(Dest, DestSize, String, Terminator) CopyStringNoFormatT_(__LINE__, Dest, DestSize, String, Terminator) int -CopyStringNoFormatT(char *Dest, char *String, char Terminator) +CopyStringNoFormatT_(int LineNumber, char *Dest, int DestSize, char *String, char Terminator) { int Length = 0; + char *Start = String; while(*String != Terminator) { *Dest++ = *String++; ++Length; } + if(Length >= DestSize) + { + printf("CopyStringNoFormatT() call on line %d has been passed a buffer too small (%d bytes) to contain %c-terminated %d(+1)-character string:\n" + "%.*s\n", LineNumber, DestSize, Terminator == 0 ? '0' : Terminator, Length, Length, Start); + __asm__("int3"); + } *Dest = '\0'; return Length; } -__attribute__ ((format (printf, 2, 3))) +#define CopyStringToBuffer(Dest, Format, ...) CopyStringToBuffer_(__LINE__, Dest, Format, ##__VA_ARGS__) +__attribute__ ((format (printf, 3, 4))) void -CopyStringToBuffer(buffer *Dest, char *Format, ...) +CopyStringToBuffer_(int LineNumber, buffer *Dest, char *Format, ...) { va_list Args; va_start(Args, Format); int Length = vsnprintf(Dest->Ptr, Dest->Size - (Dest->Ptr - Dest->Location), Format, Args); va_end(Args); - // TODO(matt) + if(Length + (Dest->Ptr - Dest->Location) >= Dest->Size) { - if(Length + (Dest->Ptr - Dest->Location) >= Dest->Size) - { - fprintf(stderr, "CopyStringToBuffer: %s cannot accommodate %d-character string:\n" - "\n" - "%s\n", Dest->ID, Length, Format); - __asm__("int3"); - } + fprintf(stderr, "CopyStringToBuffer(%s) call on line %d cannot accommodate null-terminated %d(+1)-character string:\n" + "%s\n", Dest->ID, LineNumber, Length, Format); + __asm__("int3"); } Dest->Ptr += Length; } +#define CopyStringToBufferNoFormat(Dest, String) CopyStringToBufferNoFormat_(__LINE__, Dest, String) void -CopyStringToBufferNoFormat(buffer *Dest, char *String) +CopyStringToBufferNoFormat_(int LineNumber, buffer *Dest, char *String) { + char *Start = String; while(*String) { *Dest->Ptr++ = *String++; } + if(Dest->Ptr - Dest->Location >= Dest->Size) + { + fprintf(stderr, "CopyStringToBufferNoFormat(%s) call on line %d cannot accommodate %d-character string:\n" + "%s\n", Dest->ID, LineNumber, StringLength(Start), Start); + __asm__("int3"); + } *Dest->Ptr = '\0'; } +#define CopyStringToBufferHTMLSafe(Dest, String) CopyStringToBufferHTMLSafe_(__LINE__, Dest, String) void -CopyStringToBufferHTMLSafe(buffer *Dest, char *String) +CopyStringToBufferHTMLSafe_(int LineNumber, buffer *Dest, char *String) { + char *Start = String; + int Length = StringLength(String); while(*String) { - if(Dest->Ptr - Dest->Location >= Dest->Size) - { - fprintf(stderr, "CopyStringToBufferHTMLSafe: %s cannot accommodate %d-character string\n", Dest->ID, StringLength(String)); - __asm__("int3"); - } switch(*String) { - case '<': CopyStringToBuffer(Dest, "<"); break; - case '>': CopyStringToBuffer(Dest, ">"); break; - case '&': CopyStringToBuffer(Dest, "&"); break; - case '\"': CopyStringToBuffer(Dest, """); break; - case '\'': CopyStringToBuffer(Dest, "'"); break; + case '<': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'l'; *Dest->Ptr++ = 't'; *Dest->Ptr++ = ';'; Length += 3; break; + case '>': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'g'; *Dest->Ptr++ = 't'; *Dest->Ptr++ = ';'; Length += 3; break; + case '&': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'a'; *Dest->Ptr++ = 'm'; *Dest->Ptr++ = 'p'; *Dest->Ptr++ = ';'; Length += 4; break; + case '\"': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'q'; *Dest->Ptr++ = 'u'; *Dest->Ptr++ = 'o'; *Dest->Ptr++ = 't'; *Dest->Ptr++ = ';'; Length += 5; break; + case '\'': *Dest->Ptr++ = '&'; *Dest->Ptr++ = '#'; *Dest->Ptr++ = '3'; *Dest->Ptr++ = '9'; *Dest->Ptr++ = ';'; Length += 4; break; default: *Dest->Ptr++ = *String; break; } ++String; } + if(Dest->Ptr - Dest->Location >= Dest->Size) + { + fprintf(stderr, "CopyStringToBufferHTMLSafe(%s) call on line %d cannot accommodate %d(+1)-character HTML-sanitised string:\n" + "%s\n", Dest->ID, LineNumber, Length, Start); + __asm__("int3"); + } + *Dest->Ptr = '\0'; } +#define CopyStringToBufferHTMLSafeBreakingOnSlash(Dest, String) CopyStringToBufferHTMLSafeBreakingOnSlash_(__LINE__, Dest, String) void -CopyStringToBufferHTMLSafeBreakingOnSlash(buffer *Dest, char *String) +CopyStringToBufferHTMLSafeBreakingOnSlash_(int LineNumber, buffer *Dest, char *String) { + char *Start = String; + int Length = StringLength(String); while(*String) { - if(Dest->Ptr - Dest->Location >= Dest->Size) - { - fprintf(stderr, "CopyStringToBufferHTMLSafeBreakingOnSlash: %s cannot accommodate %d-character string\n", Dest->ID, StringLength(String)); - __asm__("int3"); - } switch(*String) { - case '<': CopyStringToBuffer(Dest, "<"); break; - case '>': CopyStringToBuffer(Dest, ">"); break; - case '&': CopyStringToBuffer(Dest, "&"); break; - case '\"': CopyStringToBuffer(Dest, """); break; - case '\'': CopyStringToBuffer(Dest, "'"); break; - case '/': CopyStringToBuffer(Dest, "/\u200B"); break; + case '<': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'l'; *Dest->Ptr++ = 't'; *Dest->Ptr++ = ';'; Length += 3; break; + case '>': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'g'; *Dest->Ptr++ = 't'; *Dest->Ptr++ = ';'; Length += 3; break; + case '&': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'a'; *Dest->Ptr++ = 'm'; *Dest->Ptr++ = 'p'; *Dest->Ptr++ = ';'; Length += 4; break; + case '\'': *Dest->Ptr++ = '&'; *Dest->Ptr++ = '#'; *Dest->Ptr++ = '3'; *Dest->Ptr++ = '9'; *Dest->Ptr++ = ';'; Length += 4; break; + case '\"': *Dest->Ptr++ = '&'; *Dest->Ptr++ = 'q'; *Dest->Ptr++ = 'u'; *Dest->Ptr++ = 'o'; *Dest->Ptr++ = 't'; *Dest->Ptr++ = ';'; Length += 5; break; + case '/': *Dest->Ptr++ = '/'; *Dest->Ptr++ = '&'; *Dest->Ptr++ = '#'; *Dest->Ptr++ = '8'; *Dest->Ptr++ = '2'; *Dest->Ptr++ = '0'; *Dest->Ptr++ = '3'; *Dest->Ptr++ = ';'; Length += 7; break; default: *Dest->Ptr++ = *String; break; } ++String; } + if(Dest->Ptr - Dest->Location >= Dest->Size) + { + fprintf(stderr, "CopyStringToBufferHTMLSafeBreakingOnSlash_(%s) call on line %d cannot accommodate %d(+1)-character HTML-sanitised string:\n" + "%s\n", Dest->ID, LineNumber, Length, Start); + __asm__("int3"); + } } +#define CopyStringToBufferJSONSafe(Dest, String) CopyStringToBufferJSONSafe_(__LINE__, Dest, String) void -CopyStringToBufferJSONSafe(buffer *Dest, char *String) +CopyStringToBufferJSONSafe_(int LineNumber, buffer *Dest, char *String) { + char *Start = String; + int Length = StringLength(String); while(*String) { - if(Dest->Ptr - Dest->Location >= Dest->Size) - { - fprintf(stderr, "CopyStringToBufferJSONSafe: %s cannot accommodate %d-character string\n", Dest->ID, StringLength(String)); - __asm__("int3"); - } switch(*String) { case '\\': case '\"': *Dest->Ptr++ = '\\'; + ++Length; default: *Dest->Ptr++ = *String++; break; } } + if(Dest->Ptr - Dest->Location >= Dest->Size) + { + fprintf(stderr, "CopyStringToBufferJSONSafe(%s) call on line %d cannot accommodate %d(+1)-character JSON-sanitised string:\n" + "%s\n", Dest->ID, LineNumber, Length, Start); + __asm__("int3"); + } +} + +#define CopyBuffer(Dest, Src) CopyBuffer_(__LINE__, Dest, Src) +void +CopyBuffer_(int LineNumber, buffer *Dest, buffer *Src) +{ + Src->Ptr = Src->Location; + while(*Src->Ptr) + { + *Dest->Ptr++ = *Src->Ptr++; + } + if(Dest->Ptr - Dest->Location >= Dest->Size) + { + fprintf(stderr, "CopyBuffer(%s) call on line %d cannot accommodate %d(+1)-character %s\n", Dest->ID, LineNumber, StringLength(Src->Location), Src->ID); + __asm__("int3"); + } + *Dest->Ptr = '\0'; } int @@ -827,7 +883,7 @@ LogError(int LogLevel, char *Format, ...) if(Config.LogLevel >= LogLevel) { char LogPath[256]; - CopyString(LogPath, "%s/%s", Config.CacheDir, "errors.log"); + CopyString(LogPath, sizeof(LogPath), "%s/%s", Config.CacheDir, "errors.log"); FILE *LogFile; if(!(LogFile = fopen(LogPath, "a+"))) { @@ -853,7 +909,7 @@ void FreeBuffer(buffer *Buffer) { free(Buffer->Location); - Buffer->Location = '\0'; + Buffer->Location = 0; #if DEBUG_MEM FILE *MemLog = fopen("/home/matt/cinera_mem", "a+"); fprintf(MemLog, " Freed %s\n", Buffer->ID); @@ -993,24 +1049,25 @@ ConstructTemplatePath(template *Template, int TemplateType) if(Template->Metadata.Filename[0] != '/') { char Temp[256]; - CopyString(Temp, Template->Metadata.Filename); + CopyString(Temp, sizeof(Temp), "%s", Template->Metadata.Filename); char *Ptr = Template->Metadata.Filename; + char *End = Template->Metadata.Filename + sizeof(Template->Metadata.Filename); if(TemplateType == TEMPLATE_BESPOKE) { if(Config.Edition == EDITION_SINGLE) { - Ptr += CopyString(Ptr, "%s/", GetDirectoryPath(Config.SingleHMMLFilePath)); + Ptr += CopyString(Ptr, End - Ptr, "%s/", GetDirectoryPath(Config.SingleHMMLFilePath)); } else { - Ptr += CopyString(Ptr, "%s/", Config.ProjectDir); + Ptr += CopyString(Ptr, End - Ptr, "%s/", Config.ProjectDir); } } else { - Ptr += CopyString(Ptr, "%s/", Config.TemplatesDir); + Ptr += CopyString(Ptr, End - Ptr, "%s/", Config.TemplatesDir); } - CopyString(Ptr, "%s", Temp); + CopyString(Ptr, End - Ptr, "%s", Temp); } } @@ -1037,7 +1094,7 @@ InitTemplate(template **Template) int ClaimTemplate(template **Template, char *Location, int TemplateType) { - CopyString((*Template)->Metadata.Filename, Location); + CopyString((*Template)->Metadata.Filename, sizeof((*Template)->Metadata.Filename), "%s", Location); ConstructTemplatePath((*Template), TemplateType); if(TemplateType == TEMPLATE_BESPOKE) @@ -1225,7 +1282,7 @@ ConstructURLPrefix(buffer *URLPrefix, int IncludeType, int PageType) RewindBuffer(URLPrefix); if(StringsDiffer(Config.RootURL, "")) { - URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.RootURL); + CopyStringToBuffer(URLPrefix, "%s/", Config.RootURL); } else { @@ -1233,9 +1290,9 @@ ConstructURLPrefix(buffer *URLPrefix, int IncludeType, int PageType) { if(PageType == PAGE_PLAYER) { - URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "../"); + CopyStringToBuffer(URLPrefix, "../"); } - URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "../"); + CopyStringToBuffer(URLPrefix, "../"); } } @@ -1244,19 +1301,19 @@ ConstructURLPrefix(buffer *URLPrefix, int IncludeType, int PageType) case INCLUDE_CSS: if(StringsDiffer(Config.CSSDir, "")) { - URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.CSSDir); + CopyStringToBuffer(URLPrefix, "%s/", Config.CSSDir); } break; case INCLUDE_Images: if(StringsDiffer(Config.ImagesDir, "")) { - URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.ImagesDir); + CopyStringToBuffer(URLPrefix, "%s/", Config.ImagesDir); } break; case INCLUDE_JS: if(StringsDiffer(Config.JSDir, "")) { - URLPrefix->Ptr += CopyString(URLPrefix->Ptr, "%s/", Config.JSDir); + CopyStringToBuffer(URLPrefix, "%s/", Config.JSDir); } break; } @@ -1338,7 +1395,7 @@ SearchCredentials(buffer *CreditsMenu, bool *HasCreditsMenu, char *Person, char ClaimBuffer(&URLPrefix, "URLPrefix", 1024); ConstructURLPrefix(&URLPrefix, INCLUDE_Images, PAGE_PLAYER); CopyStringToBuffer(CreditsMenu, - "
\n", + "
\n", Credentials[CredentialIndex].SupportURL, URLPrefix.Location, Credentials[CredentialIndex].SupportIcon); @@ -1353,7 +1410,7 @@ SearchCredentials(buffer *CreditsMenu, bool *HasCreditsMenu, char *Person, char } void -ClearString(char *String) +ClearNullTerminatedString(char *String) { while(*String) { @@ -1364,7 +1421,7 @@ ClearString(char *String) void InitialString(char *Dest, char *Src) { - ClearString(Dest); + ClearNullTerminatedString(Dest); *Dest++ = *Src++; while(*Src++) { @@ -1382,7 +1439,7 @@ InitialString(char *Dest, char *Src) void GetFirstSubstring(char *Dest, char *Src) { - ClearString(Dest); + ClearNullTerminatedString(Dest); while(*Src && *Src != ' ') { *Dest++ = *Src++; @@ -1390,9 +1447,9 @@ GetFirstSubstring(char *Dest, char *Src) } void -InitialAndGetFinalString(char *Dest, char *Src) +InitialAndGetFinalString(char *Dest, int DestSize, char *Src) { - ClearString(Dest); + ClearNullTerminatedString(Dest); int SrcLength = StringLength(Src); char *SrcPtr = Src + SrcLength - 1; while(SrcPtr > Src && *SrcPtr != ' ') @@ -1426,7 +1483,7 @@ InitialAndGetFinalString(char *Dest, char *Src) } } - CopyString(Dest, SrcPtr); + CopyString(Dest, DestSize, "%s", SrcPtr); } bool @@ -1476,7 +1533,7 @@ SortAndAbbreviateSpeakers(speakers *Speakers) switch(Attempt) { case 0: GetFirstSubstring(Speakers->Speaker[i].Abbreviation, Speakers->Speaker[i].Credential->CreditedName); break; - case 1: InitialAndGetFinalString(Speakers->Speaker[i].Abbreviation, Speakers->Speaker[i].Credential->CreditedName); break; + case 1: InitialAndGetFinalString(Speakers->Speaker[i].Abbreviation, sizeof(Speakers->Speaker[i].Abbreviation), Speakers->Speaker[i].Credential->CreditedName); break; case 2: ClearCopyStringNoFormat(Speakers->Speaker[i].Abbreviation, sizeof(Speakers->Speaker[i].Abbreviation), Speakers->Speaker[i].Credential->Username); break; } } @@ -1586,14 +1643,14 @@ BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMM { if(Ref->isbn) { - CopyString(ReferencesArray[UniqueRefs].ID, Ref->isbn); - if(!Ref->url) { CopyString(ReferencesArray[UniqueRefs].URL, "https://isbndb.com/book/%s", Ref->isbn); } - else { CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url); } + CopyString(ReferencesArray[UniqueRefs].ID, sizeof(ReferencesArray[UniqueRefs].ID), "%s", Ref->isbn); + if(!Ref->url) { CopyString(ReferencesArray[UniqueRefs].URL, sizeof(ReferencesArray[UniqueRefs].URL), "https://isbndb.com/book/%s", Ref->isbn); } + else { CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, sizeof(ReferencesArray[UniqueRefs].URL), Ref->url); } } else if(Ref->url) { - CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, Ref->url); - CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, Ref->url); + CopyStringNoFormat(ReferencesArray[UniqueRefs].ID, sizeof(ReferencesArray[UniqueRefs].ID), Ref->url); + CopyStringNoFormat(ReferencesArray[UniqueRefs].URL, sizeof(ReferencesArray[UniqueRefs].URL), Ref->url); } else { return RC_INVALID_REFERENCE; } @@ -1612,56 +1669,56 @@ BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMM { case (REF_TITLE | REF_AUTHOR | REF_PUBLISHER): { - CopyString(ReferencesArray[UniqueRefs].Source, "%s (%s)", Ref->author, Ref->publisher); - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title); + CopyString(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), "%s (%s)", Ref->author, Ref->publisher); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->title); } break; case (REF_AUTHOR | REF_SITE | REF_PAGE): { - CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site); - CopyString(ReferencesArray[UniqueRefs].RefTitle, "%s: \"%s\"", Ref->author, Ref->page); + CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), Ref->site); + CopyString(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), "%s: \"%s\"", Ref->author, Ref->page); } break; case (REF_PAGE | REF_TITLE): { - CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->title); - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->page); + CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), Ref->title); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->page); } break; case (REF_SITE | REF_PAGE): { - CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site); - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->page); + CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), Ref->site); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->page); } break; case (REF_SITE | REF_TITLE): { - CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->site); - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title); + CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), Ref->site); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->title); } break; case (REF_TITLE | REF_AUTHOR): { - CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->author); - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title); + CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), Ref->author); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->title); } break; case (REF_ARTICLE | REF_AUTHOR): { - CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->author); - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->article); + CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), Ref->author); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->article); } break; case (REF_TITLE | REF_PUBLISHER): { - CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, Ref->publisher); - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title); + CopyStringNoFormat(ReferencesArray[UniqueRefs].Source, sizeof(ReferencesArray[UniqueRefs].Source), Ref->publisher); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->title); } break; case REF_TITLE: { - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->title); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->title); } break; case REF_SITE: { - CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, Ref->site); + CopyStringNoFormat(ReferencesArray[UniqueRefs].RefTitle, sizeof(ReferencesArray[UniqueRefs].RefTitle), Ref->site); } break; default: return RC_INVALID_REFERENCE; break; } - CopyString(ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Timecode, Anno->time); + CopyString(ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Timecode, sizeof(ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Timecode), "%s", Anno->time); ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Identifier = RefIdentifier; return RC_SUCCESS; } @@ -1695,20 +1752,20 @@ InsertCategory(categories *GlobalTopics, categories *LocalTopics, categories *Gl int CategoryCount; for(CategoryCount = LocalMedia->Count; CategoryCount > MediumIndex; --CategoryCount) { - CopyString(LocalMedia->Category[CategoryCount].Marker, LocalMedia->Category[CategoryCount-1].Marker); - CopyString(LocalMedia->Category[CategoryCount].WrittenText, LocalMedia->Category[CategoryCount-1].WrittenText); + CopyString(LocalMedia->Category[CategoryCount].Marker, sizeof(LocalMedia->Category[CategoryCount].Marker), "%s", LocalMedia->Category[CategoryCount-1].Marker); + CopyString(LocalMedia->Category[CategoryCount].WrittenText, sizeof(LocalMedia->Category[CategoryCount].WrittenText), "%s", LocalMedia->Category[CategoryCount-1].WrittenText); } - CopyString(LocalMedia->Category[CategoryCount].Marker, CategoryMedium[CategoryMediumIndex].Medium); - CopyString(LocalMedia->Category[CategoryCount].WrittenText, CategoryMedium[CategoryMediumIndex].WrittenName); + CopyString(LocalMedia->Category[CategoryCount].Marker, sizeof(LocalMedia->Category[CategoryCount].Marker), "%s", CategoryMedium[CategoryMediumIndex].Medium); + CopyString(LocalMedia->Category[CategoryCount].WrittenText, sizeof(LocalMedia->Category[CategoryCount].WrittenText), "%s", CategoryMedium[CategoryMediumIndex].WrittenName); break; } } if(MediumIndex == LocalMedia->Count) { - CopyString(LocalMedia->Category[MediumIndex].Marker, CategoryMedium[CategoryMediumIndex].Medium); - CopyString(LocalMedia->Category[MediumIndex].WrittenText, CategoryMedium[CategoryMediumIndex].WrittenName); + CopyString(LocalMedia->Category[MediumIndex].Marker, sizeof(LocalMedia->Category[MediumIndex].Marker), "%s", CategoryMedium[CategoryMediumIndex].Medium); + CopyString(LocalMedia->Category[MediumIndex].WrittenText, sizeof(LocalMedia->Category[MediumIndex].WrittenText), "%s", CategoryMedium[CategoryMediumIndex].WrittenName); } ++LocalMedia->Count; @@ -1724,20 +1781,20 @@ InsertCategory(categories *GlobalTopics, categories *LocalTopics, categories *Gl int CategoryCount; for(CategoryCount = GlobalMedia->Count; CategoryCount > MediumIndex; --CategoryCount) { - CopyString(GlobalMedia->Category[CategoryCount].Marker, GlobalMedia->Category[CategoryCount-1].Marker); - CopyString(GlobalMedia->Category[CategoryCount].WrittenText, GlobalMedia->Category[CategoryCount-1].WrittenText); + CopyString(GlobalMedia->Category[CategoryCount].Marker, sizeof(GlobalMedia->Category[CategoryCount].Marker), "%s", GlobalMedia->Category[CategoryCount-1].Marker); + CopyString(GlobalMedia->Category[CategoryCount].WrittenText, sizeof(GlobalMedia->Category[CategoryCount].WrittenText), "%s", GlobalMedia->Category[CategoryCount-1].WrittenText); } - CopyString(GlobalMedia->Category[CategoryCount].Marker, CategoryMedium[CategoryMediumIndex].Medium); - CopyString(GlobalMedia->Category[CategoryCount].WrittenText, CategoryMedium[CategoryMediumIndex].WrittenName); + CopyString(GlobalMedia->Category[CategoryCount].Marker, sizeof(GlobalMedia->Category[CategoryCount].Marker), "%s", CategoryMedium[CategoryMediumIndex].Medium); + CopyString(GlobalMedia->Category[CategoryCount].WrittenText, sizeof(GlobalMedia->Category[CategoryCount].WrittenText), "%s", CategoryMedium[CategoryMediumIndex].WrittenName); break; } } if(MediumIndex == GlobalMedia->Count) { - CopyString(GlobalMedia->Category[MediumIndex].Marker, CategoryMedium[CategoryMediumIndex].Medium); - CopyString(GlobalMedia->Category[MediumIndex].WrittenText, CategoryMedium[CategoryMediumIndex].WrittenName); + CopyString(GlobalMedia->Category[MediumIndex].Marker, sizeof(GlobalMedia->Category[MediumIndex].Marker), "%s", CategoryMedium[CategoryMediumIndex].Medium); + CopyString(GlobalMedia->Category[MediumIndex].WrittenText, sizeof(GlobalMedia->Category[MediumIndex].WrittenText), "%s", CategoryMedium[CategoryMediumIndex].WrittenName); } ++GlobalMedia->Count; @@ -1756,17 +1813,17 @@ InsertCategory(categories *GlobalTopics, categories *LocalTopics, categories *Gl int CategoryCount; for(CategoryCount = LocalTopics->Count; CategoryCount > TopicIndex; --CategoryCount) { - CopyString(LocalTopics->Category[CategoryCount].Marker, LocalTopics->Category[CategoryCount-1].Marker); + CopyString(LocalTopics->Category[CategoryCount].Marker, sizeof(LocalTopics->Category[CategoryCount].Marker), "%s", LocalTopics->Category[CategoryCount-1].Marker); } - CopyString(LocalTopics->Category[CategoryCount].Marker, Marker); + CopyString(LocalTopics->Category[CategoryCount].Marker, sizeof(LocalTopics->Category[CategoryCount].Marker), "%s", Marker); break; } } if(TopicIndex == LocalTopics->Count) { - CopyString(LocalTopics->Category[TopicIndex].Marker, Marker); + CopyString(LocalTopics->Category[TopicIndex].Marker, sizeof(LocalTopics->Category[TopicIndex].Marker), "%s", Marker); } ++LocalTopics->Count; @@ -1786,10 +1843,10 @@ InsertCategory(categories *GlobalTopics, categories *LocalTopics, categories *Gl int CategoryCount; for(CategoryCount = GlobalTopics->Count; CategoryCount > TopicIndex; --CategoryCount) { - CopyString(GlobalTopics->Category[CategoryCount].Marker, GlobalTopics->Category[CategoryCount-1].Marker); + CopyString(GlobalTopics->Category[CategoryCount].Marker, sizeof(GlobalTopics->Category[CategoryCount].Marker), "%s", GlobalTopics->Category[CategoryCount-1].Marker); } - CopyString(GlobalTopics->Category[CategoryCount].Marker, Marker); + CopyString(GlobalTopics->Category[CategoryCount].Marker, sizeof(GlobalTopics->Category[CategoryCount].Marker), "%s", Marker); break; } } @@ -1797,7 +1854,7 @@ InsertCategory(categories *GlobalTopics, categories *LocalTopics, categories *Gl if(TopicIndex == GlobalTopics->Count) { - CopyString(GlobalTopics->Category[TopicIndex].Marker, Marker); + CopyString(GlobalTopics->Category[TopicIndex].Marker, sizeof(GlobalTopics->Category[TopicIndex].Marker), "%s", Marker); } ++GlobalTopics->Count; @@ -1817,8 +1874,8 @@ BuildCategories(buffer *AnnotationClass, buffer *CategoryIcons, categories *Loca if(LocalTopics->Count == 1 && !StringsDiffer(LocalTopics->Category[0].Marker, "nullTopic")) { - char SanitisedMarker[StringLength(LocalTopics->Category[0].Marker)]; - CopyString(SanitisedMarker, LocalTopics->Category[0].Marker); + char SanitisedMarker[StringLength(LocalTopics->Category[0].Marker) + 1]; + CopyString(SanitisedMarker, sizeof(SanitisedMarker), "%s", LocalTopics->Category[0].Marker); SanitisePunctuation(SanitisedMarker); CopyStringToBuffer(AnnotationClass, " cat_%s", SanitisedMarker); } @@ -1826,8 +1883,8 @@ BuildCategories(buffer *AnnotationClass, buffer *CategoryIcons, categories *Loca { for(int i = 0; i < LocalTopics->Count; ++i) { - char SanitisedMarker[StringLength(LocalTopics->Category[i].Marker)]; - CopyString(SanitisedMarker, LocalTopics->Category[i].Marker); + char SanitisedMarker[StringLength(LocalTopics->Category[i].Marker) + 1]; + CopyString(SanitisedMarker, sizeof(SanitisedMarker), "%s", LocalTopics->Category[i].Marker); SanitisePunctuation(SanitisedMarker); CopyStringToBuffer(CategoryIcons, "
", @@ -1841,8 +1898,8 @@ BuildCategories(buffer *AnnotationClass, buffer *CategoryIcons, categories *Loca if(LocalMedia->Count == 1 && !StringsDiffer(LocalMedia->Category[0].Marker, DefaultMedium)) { - char SanitisedMarker[StringLength(LocalMedia->Category[0].Marker)]; - CopyString(SanitisedMarker, LocalMedia->Category[0].Marker); + char SanitisedMarker[StringLength(LocalMedia->Category[0].Marker) + 1]; + CopyString(SanitisedMarker, sizeof(SanitisedMarker), "%s", LocalMedia->Category[0].Marker); SanitisePunctuation(SanitisedMarker); CopyStringToBuffer(AnnotationClass, " %s", SanitisedMarker); } @@ -1850,8 +1907,8 @@ BuildCategories(buffer *AnnotationClass, buffer *CategoryIcons, categories *Loca { for(int i = 0; i < LocalMedia->Count; ++i) { - char SanitisedMarker[StringLength(LocalMedia->Category[i].Marker)]; - CopyString(SanitisedMarker, LocalMedia->Category[i].Marker); + char SanitisedMarker[StringLength(LocalMedia->Category[i].Marker) + 1]; + CopyString(SanitisedMarker, sizeof(SanitisedMarker), "%s", LocalMedia->Category[i].Marker); SanitisePunctuation(SanitisedMarker); if(!StringsDiffer(LocalMedia->Category[i].Marker, "afk")) // TODO(matt): Initially hidden config @@ -1932,34 +1989,29 @@ SearchQuotes(buffer *QuoteStaging, int CacheSize, quote_info *Info, int ID) QuoteStaging->Ptr = QuoteStaging->Location; while(QuoteStaging->Ptr - QuoteStaging->Location < CacheSize) { - char InID[4] = { 0 }; + char InID[8] = { 0 }; char InTime[16] = { 0 }; - char *OutPtr = InID; - QuoteStaging->Ptr += CopyStringNoFormatT(OutPtr, QuoteStaging->Ptr, ','); + QuoteStaging->Ptr += CopyStringNoFormatT(InID, sizeof(InID), QuoteStaging->Ptr, ',') + 1; // Skip past the ',' if(StringToInt(InID) == ID) { - QuoteStaging->Ptr += 1; - OutPtr = InTime; - QuoteStaging->Ptr += CopyStringNoFormatT(OutPtr, QuoteStaging->Ptr, ','); + QuoteStaging->Ptr += CopyStringNoFormatT(InTime, sizeof(InTime), QuoteStaging->Ptr, ',') + 1; // Skip past the ',' long int Time = StringToInt(InTime); - char DayString[3]; + char DayString[3] = { 0 }; strftime(DayString, 3, "%d", gmtime(&Time)); int Day = StringToInt(DayString); - char DaySuffix[3]; if(DayString[1] == '1' && Day != 11) { CopyString(DaySuffix, "st"); } - else if(DayString[1] == '2' && Day != 12) { CopyString(DaySuffix, "nd"); } - else if(DayString[1] == '3' && Day != 13) { CopyString(DaySuffix, "rd"); } - else { CopyString(DaySuffix, "th"); } + char DaySuffix[3]; if(DayString[1] == '1' && Day != 11) { CopyString(DaySuffix, sizeof(DaySuffix), "st"); } + else if(DayString[1] == '2' && Day != 12) { CopyString(DaySuffix, sizeof(DaySuffix), "nd"); } + else if(DayString[1] == '3' && Day != 13) { CopyString(DaySuffix, sizeof(DaySuffix), "rd"); } + else { CopyString(DaySuffix, sizeof(DaySuffix), "th"); } char MonthYear[32]; strftime(MonthYear, 32, "%B, %Y", gmtime(&Time)); - CopyString(Info->Date, "%d%s %s", Day, DaySuffix, MonthYear); + CopyString(Info->Date, sizeof(Info->Date), "%d%s %s", Day, DaySuffix, MonthYear); - QuoteStaging->Ptr += 1; - OutPtr = Info->Text; - QuoteStaging->Ptr += CopyStringNoFormatT(OutPtr, QuoteStaging->Ptr, '\n'); + CopyStringNoFormatT(Info->Text, sizeof(Info->Text), QuoteStaging->Ptr, '\n'); FreeBuffer(QuoteStaging); return RC_FOUND; @@ -1980,14 +2032,14 @@ int BuildQuote(quote_info *Info, char *Speaker, int ID, bool ShouldFetchQuotes) { char QuoteCacheDir[256]; - CopyString(QuoteCacheDir, "%s/quotes", Config.CacheDir); + CopyString(QuoteCacheDir, sizeof(QuoteCacheDir), "%s/quotes", Config.CacheDir); char QuoteCachePath[256]; - CopyString(QuoteCachePath, "%s/%s", QuoteCacheDir, Speaker); + CopyString(QuoteCachePath, sizeof(QuoteCachePath), "%s/%s", QuoteCacheDir, Speaker); FILE *QuoteCache; char QuotesURL[256]; // TODO(matt): Make the URL configurable and also handle the case in which the .raw isn't available - CopyString(QuotesURL, "https://dev.abaines.me.uk/quotes/%s.raw", Speaker); + CopyString(QuotesURL, sizeof(QuotesURL), "https://dev.abaines.me.uk/quotes/%s.raw", Speaker); bool CacheAvailable = FALSE; if(!(QuoteCache = fopen(QuoteCachePath, "a+"))) @@ -2075,8 +2127,8 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, bool ShouldFetchQuotes) int GenerateTopicColours(char *Topic) { - char SanitisedTopic[StringLength(Topic)]; - CopyString(SanitisedTopic, Topic); + char SanitisedTopic[StringLength(Topic) + 1]; + CopyString(SanitisedTopic, sizeof(SanitisedTopic), "%s", Topic); SanitisePunctuation(SanitisedTopic); for(int i = 0; i < ArrayCount(CategoryMedium); ++i) @@ -2092,11 +2144,11 @@ GenerateTopicColours(char *Topic) if(StringsDiffer(Config.CSSDir, "")) { - CopyString(Topics.Path, "%s/%s/cinera_topics.css", Config.RootDir, Config.CSSDir); + CopyString(Topics.Path, sizeof(Topics.Path), "%s/%s/cinera_topics.css", Config.RootDir, Config.CSSDir); } else { - CopyString(Topics.Path, "%s/cinera_topics.css", Config.RootDir); + CopyString(Topics.Path, sizeof(Topics.Path), "%s/cinera_topics.css", Config.RootDir); } char *Ptr = Topics.Path + StringLength(Topics.Path) - 1; @@ -2788,7 +2840,6 @@ SeekBufferForString(buffer *Buffer, char *String, } #define HMMLCleanup() \ - DeclaimBuffer(&FilterState); \ DeclaimBuffer(&CreditsMenu); \ DeclaimBuffer(&FilterMedia); \ DeclaimBuffer(&FilterTopics); \ @@ -2813,8 +2864,8 @@ VideoIsPrivate(char *VideoID) { // NOTE(matt): Currently only supports YouTube char Message[128]; - CopyString(Message, "\e[0;35mChecking\e[0m privacy status of: https://youtube.com/watch?v=%s", VideoID); - fprintf(stderr, Message); + CopyString(Message, sizeof(Message), "\e[0;35mChecking\e[0m privacy status of: https://youtube.com/watch?v=%s", VideoID); + fprintf(stderr, "%s", Message); int MessageLength = StringLength(Message); buffer VideoAPIResponse; ClaimBuffer(&VideoAPIResponse, "VideoAPIResponse", Kilobytes(1)); @@ -2824,7 +2875,7 @@ VideoIsPrivate(char *VideoID) LastPrivacyCheck = time(0); #define APIKey "AIzaSyAdV2U8ivPk8PHMaPMId0gynksw_gdzr9k" char URL[1024] = {0}; - CopyString(URL, "https://www.googleapis.com/youtube/v3/videos?key=%s&part=status&id=%s", APIKey, VideoID); + CopyString(URL, sizeof(URL), "https://www.googleapis.com/youtube/v3/videos?key=%s&part=status&id=%s", APIKey, VideoID); CURLcode CurlReturnCode; curl_easy_setopt(curl, CURLOPT_WRITEDATA, &VideoAPIResponse.Ptr); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlIntoBuffer); @@ -2848,7 +2899,7 @@ VideoIsPrivate(char *VideoID) SeekBufferForString(&VideoAPIResponse, "{", C_SEEK_FORWARDS, C_SEEK_AFTER); SeekBufferForString(&VideoAPIResponse, "\"privacyStatus\": \"", C_SEEK_FORWARDS, C_SEEK_AFTER); char Status[16]; - CopyStringNoFormatT(Status, VideoAPIResponse.Ptr, '\"'); + CopyStringNoFormatT(Status, sizeof(Status), VideoAPIResponse.Ptr, '\"'); if(!StringsDiffer(Status, "public")) { DeclaimBuffer(&VideoAPIResponse); @@ -2925,11 +2976,11 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen char Filepath[256]; if(Config.Edition == EDITION_PROJECT) { - CopyString(Filepath, "%s/%s", Config.ProjectDir, Filename); + CopyString(Filepath, sizeof(Filepath), "%s/%s", Config.ProjectDir, Filename); } else { - CopyString(Filepath, "%s", Filename); + CopyString(Filepath, sizeof(Filepath), "%s", Filename); } FILE *InFile; @@ -2966,7 +3017,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen } else { - CopyString(CollationBuffers->Title, HMML.metadata.title); + CopyString(CollationBuffers->Title, sizeof(CollationBuffers->Title), "%s", HMML.metadata.title); } if(!HMML.metadata.member) @@ -2991,12 +3042,12 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen fprintf(stderr, "Please set the id attribute in the [video] node of your .hmml file\n"); HaveErrors = TRUE; } - CopyString(CollationBuffers->VideoID, HMML.metadata.id); + CopyString(CollationBuffers->VideoID, sizeof(CollationBuffers->VideoID), "%s", HMML.metadata.id); buffer URLPlayer; ClaimBuffer(&URLPlayer, "URLPlayer", MAX_BASE_URL_LENGTH + 1 + MAX_RELATIVE_PAGE_LOCATION_LENGTH + 1 + MAX_PLAYER_URL_PREFIX_LENGTH + MAX_BASE_FILENAME_LENGTH); ConstructPlayerURL(&URLPlayer, BaseFilename); - CopyString(CollationBuffers->URLPlayer, URLPlayer.Location); + CopyString(CollationBuffers->URLPlayer, sizeof(CollationBuffers->URLPlayer), "%s", URLPlayer.Location); DeclaimBuffer(&URLPlayer); for(int ProjectIndex = 0; ProjectIndex < ArrayCount(ProjectInfo); ++ProjectIndex) @@ -3006,7 +3057,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen HMML.metadata.project : Config.ProjectID)) { - CopyString(CollationBuffers->ProjectName, ProjectInfo[ProjectIndex].FullName); + CopyString(CollationBuffers->ProjectName, sizeof(CollationBuffers->ProjectName), "%s", ProjectInfo[ProjectIndex].FullName); break; } } @@ -3046,22 +3097,22 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen { switch(CustomIndex) { - case 0: CopyStringNoFormat(CollationBuffers->Custom0, HMML.metadata.custom[CustomIndex]); break; - case 1: CopyStringNoFormat(CollationBuffers->Custom1, HMML.metadata.custom[CustomIndex]); break; - case 2: CopyStringNoFormat(CollationBuffers->Custom2, HMML.metadata.custom[CustomIndex]); break; - case 3: CopyStringNoFormat(CollationBuffers->Custom3, HMML.metadata.custom[CustomIndex]); break; - case 4: CopyStringNoFormat(CollationBuffers->Custom4, HMML.metadata.custom[CustomIndex]); break; - case 5: CopyStringNoFormat(CollationBuffers->Custom5, HMML.metadata.custom[CustomIndex]); break; - case 6: CopyStringNoFormat(CollationBuffers->Custom6, HMML.metadata.custom[CustomIndex]); break; - case 7: CopyStringNoFormat(CollationBuffers->Custom7, HMML.metadata.custom[CustomIndex]); break; - case 8: CopyStringNoFormat(CollationBuffers->Custom8, HMML.metadata.custom[CustomIndex]); break; - case 9: CopyStringNoFormat(CollationBuffers->Custom9, HMML.metadata.custom[CustomIndex]); break; - case 10: CopyStringNoFormat(CollationBuffers->Custom10, HMML.metadata.custom[CustomIndex]); break; - case 11: CopyStringNoFormat(CollationBuffers->Custom11, HMML.metadata.custom[CustomIndex]); break; - case 12: CopyStringNoFormat(CollationBuffers->Custom12, HMML.metadata.custom[CustomIndex]); break; - case 13: CopyStringNoFormat(CollationBuffers->Custom13, HMML.metadata.custom[CustomIndex]); break; - case 14: CopyStringNoFormat(CollationBuffers->Custom14, HMML.metadata.custom[CustomIndex]); break; - case 15: CopyStringNoFormat(CollationBuffers->Custom15, HMML.metadata.custom[CustomIndex]); break; + case 0: CopyStringNoFormat(CollationBuffers->Custom0, sizeof(CollationBuffers->Custom0), HMML.metadata.custom[CustomIndex]); break; + case 1: CopyStringNoFormat(CollationBuffers->Custom1, sizeof(CollationBuffers->Custom1), HMML.metadata.custom[CustomIndex]); break; + case 2: CopyStringNoFormat(CollationBuffers->Custom2, sizeof(CollationBuffers->Custom2), HMML.metadata.custom[CustomIndex]); break; + case 3: CopyStringNoFormat(CollationBuffers->Custom3, sizeof(CollationBuffers->Custom3), HMML.metadata.custom[CustomIndex]); break; + case 4: CopyStringNoFormat(CollationBuffers->Custom4, sizeof(CollationBuffers->Custom4), HMML.metadata.custom[CustomIndex]); break; + case 5: CopyStringNoFormat(CollationBuffers->Custom5, sizeof(CollationBuffers->Custom5), HMML.metadata.custom[CustomIndex]); break; + case 6: CopyStringNoFormat(CollationBuffers->Custom6, sizeof(CollationBuffers->Custom6), HMML.metadata.custom[CustomIndex]); break; + case 7: CopyStringNoFormat(CollationBuffers->Custom7, sizeof(CollationBuffers->Custom7), HMML.metadata.custom[CustomIndex]); break; + case 8: CopyStringNoFormat(CollationBuffers->Custom8, sizeof(CollationBuffers->Custom8), HMML.metadata.custom[CustomIndex]); break; + case 9: CopyStringNoFormat(CollationBuffers->Custom9, sizeof(CollationBuffers->Custom9), HMML.metadata.custom[CustomIndex]); break; + case 10: CopyStringNoFormat(CollationBuffers->Custom10, sizeof(CollationBuffers->Custom10), HMML.metadata.custom[CustomIndex]); break; + case 11: CopyStringNoFormat(CollationBuffers->Custom11, sizeof(CollationBuffers->Custom11), HMML.metadata.custom[CustomIndex]); break; + case 12: CopyStringNoFormat(CollationBuffers->Custom12, sizeof(CollationBuffers->Custom12), HMML.metadata.custom[CustomIndex]); break; + case 13: CopyStringNoFormat(CollationBuffers->Custom13, sizeof(CollationBuffers->Custom13), HMML.metadata.custom[CustomIndex]); break; + case 14: CopyStringNoFormat(CollationBuffers->Custom14, sizeof(CollationBuffers->Custom14), HMML.metadata.custom[CustomIndex]); break; + case 15: CopyStringNoFormat(CollationBuffers->Custom15, sizeof(CollationBuffers->Custom15), HMML.metadata.custom[CustomIndex]); break; } } } @@ -3120,7 +3171,6 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen // CreditsMenu // Player // Script - // FilterState buffer QuoteMenu; buffer ReferenceMenu; @@ -3136,19 +3186,16 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen buffer Text; buffer CategoryIcons; - buffer FilterState; - if(ClaimBuffer(&QuoteMenu, "QuoteMenu", Kilobytes(32)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; if(ClaimBuffer(&ReferenceMenu, "ReferenceMenu", Kilobytes(32)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; if(ClaimBuffer(&FilterMenu, "FilterMenu", Kilobytes(16)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; if(ClaimBuffer(&FilterTopics, "FilterTopics", Kilobytes(8)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; if(ClaimBuffer(&FilterMedia, "FilterMedia", Kilobytes(8)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; if(ClaimBuffer(&CreditsMenu, "CreditsMenu", Kilobytes(8)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; - if(ClaimBuffer(&FilterState, "FilterState", Kilobytes(4)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; - ref_info ReferencesArray[200] = { 0 }; - categories Topics = { 0 }; - categories Media = { 0 }; + ref_info ReferencesArray[200] = { }; + categories Topics = { }; + categories Media = { }; bool HasQuoteMenu = FALSE; bool HasReferenceMenu = FALSE; @@ -3200,7 +3247,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen CopyStringToBuffer(&CollationBuffers->Player, "
\n"); - speakers Speakers = { 0 }; + speakers Speakers = { }; switch(BuildCredits(&CreditsMenu, &HasCreditsMenu, &HMML.metadata, &Speakers)) { case CreditsError_NoHost: @@ -3228,8 +3275,19 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen if(Config.Edition != EDITION_SINGLE && !PrivateVideo) { RewindBuffer(&CollationBuffers->Search); - CopyStringToBuffer(&CollationBuffers->Search, "name: \"%s\"\n" - "title: \"", BaseFilename); + CopyStringToBuffer(&CollationBuffers->Search, "name: \""); + if(StringsDiffer(Config.PlayerURLPrefix, "")) + { + char *Ptr = BaseFilename + StringLength(Config.ProjectID); + CopyStringToBuffer(&CollationBuffers->Search, "%s%s", Config.PlayerURLPrefix, Ptr); + } + else + { + CopyStringToBuffer(&CollationBuffers->Search, "%s", BaseFilename); + } + + CopyStringToBuffer(&CollationBuffers->Search, "\"\n" + "title: \""); CopyStringToBufferJSONSafe(&CollationBuffers->Search, HMML.metadata.title); CopyStringToBuffer(&CollationBuffers->Search, "\"\n" "markers:\n"); @@ -3259,19 +3317,12 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen } PreviousTimecode = TimecodeToSeconds(Anno->time); - if(Config.Edition != EDITION_SINGLE && !PrivateVideo) - { - CopyStringToBuffer(&CollationBuffers->Search, "\"%d\": \"", TimecodeToSeconds(Anno->time)); - CopyStringToBufferJSONSafe(&CollationBuffers->Search, Anno->text); - CopyStringToBuffer(&CollationBuffers->Search, "\"\n"); - } - - categories LocalTopics = { 0 }; - categories LocalMedia = { 0 }; + categories LocalTopics = { }; + categories LocalMedia = { }; bool HasQuote = FALSE; bool HasReference = FALSE; - quote_info QuoteInfo = { 0 }; + quote_info QuoteInfo = { }; // NOTE(matt): Tree structure of "annotation local" buffer dependencies // Annotation @@ -3310,8 +3361,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen StringToColourHash(&AuthorColour, Anno->author); // TODO(matt): That EDITION_NETWORK site database API-polling stuff CopyStringToBuffer(&Text, - "%s ", - AuthorColour.Hue, AuthorColour.Saturation, AuthorColour.Lightness, + "%s ", AuthorColour.Hue, AuthorColour.Saturation, Anno->author); } @@ -3323,11 +3373,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen } CopyStringToBuffer(&Text, - "%s: ", - Speakers.Speaker[SpeakerIndex].Colour.Hue, - Speakers.Speaker[SpeakerIndex].Colour.Saturation, - Speakers.Speaker[SpeakerIndex].Colour.Lightness, - + "%s: ", Speakers.Speaker[SpeakerIndex].Colour.Hue, Speakers.Speaker[SpeakerIndex].Colour.Saturation, @@ -3357,9 +3403,8 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen hsl_colour Colour; StringToColourHash(&Colour, Anno->markers[MarkerIndex].marker); CopyStringToBuffer(&Text, - "%.*s", + "%.*s", Anno->markers[MarkerIndex].type == HMML_MEMBER ? "member" : "project", - Colour.Hue, Colour.Saturation, Colour.Lightness, Colour.Hue, Colour.Saturation, StringLength(Readable), InPtr); @@ -3432,7 +3477,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen { if(!StringsDiffer(CurrentRef->isbn, ReferencesArray[i].ID)) { - CopyString(ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Timecode, Anno->time); + CopyString(ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Timecode, sizeof(ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Timecode), "%s", Anno->time); ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Identifier = RefIdentifier; ++ReferencesArray[i].IdentifierCount; goto AppendedIdentifier; @@ -3442,7 +3487,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen { if(!StringsDiffer(CurrentRef->url, ReferencesArray[i].ID)) { - CopyString(ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Timecode, Anno->time); + CopyString(ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Timecode, sizeof(ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Timecode), "%s", Anno->time); ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Identifier = RefIdentifier; ++ReferencesArray[i].IdentifierCount; goto AppendedIdentifier; @@ -3511,7 +3556,7 @@ AppendedIdentifier: } } - CopyStringToBuffer(&Text, "%s%d", + CopyStringToBuffer(&Text, "%s%d", Anno->references[RefIndex].offset == Anno->references[RefIndex-1].offset ? "," : "", RefIdentifier); @@ -3626,10 +3671,26 @@ AppendedIdentifier: CopyStringToBufferHTMLSafe(&Text, QuoteInfo.Text); CopyStringToBuffer(&Text, "”"); } - CopyStringToBuffer(&Text, "&#%d;", QuoteIdentifier); + CopyStringToBuffer(&Text, "&#%d;", QuoteIdentifier); ++QuoteIdentifier; } + if(Config.Edition != EDITION_SINGLE && !PrivateVideo) + { + CopyStringToBuffer(&CollationBuffers->Search, "\"%d\": \"", TimecodeToSeconds(Anno->time)); + if(Anno->is_quote && !Anno->text[0]) + { + CopyStringToBuffer(&CollationBuffers->Search, "\u201C"); + CopyStringToBufferJSONSafe(&CollationBuffers->Search, QuoteInfo.Text); + CopyStringToBuffer(&CollationBuffers->Search, "\u201D"); + } + else + { + CopyStringToBufferJSONSafe(&CollationBuffers->Search, Anno->text); + } + CopyStringToBuffer(&CollationBuffers->Search, "\"\n"); + } + while(MarkerIndex < Anno->marker_count) { switch(GenerateTopicColours(Anno->markers[MarkerIndex].marker)) @@ -3814,70 +3875,6 @@ AppendedIdentifier: if(HasFilterMenu) { - // NOTE(matt): Two loops, one for each JS "object" - CopyStringToBuffer(&FilterState, "\n"); - buffer URLPrefix; ClaimBuffer(&URLPrefix, "URLPrefix", 1024); ConstructURLPrefix(&URLPrefix, INCLUDE_Images, PAGE_PLAYER); @@ -3897,8 +3894,8 @@ AppendedIdentifier: "
Topics
\n"); for(int i = 0; i < Topics.Count; ++i) { - char SanitisedMarker[StringLength(Topics.Category[i].Marker)]; - CopyString(SanitisedMarker, Topics.Category[i].Marker); + char SanitisedMarker[StringLength(Topics.Category[i].Marker) + 1]; + CopyString(SanitisedMarker, sizeof(SanitisedMarker), "%s", Topics.Category[i].Marker); SanitisePunctuation(SanitisedMarker); bool NullTopic = !StringsDiffer(Topics.Category[i].Marker, "nullTopic"); @@ -3924,8 +3921,8 @@ AppendedIdentifier: "
Media
\n"); for(int i = 0; i < Media.Count; ++i) { - char SanitisedMarker[StringLength(Media.Category[i].Marker)]; - CopyString(SanitisedMarker, Media.Category[i].Marker); + char SanitisedMarker[StringLength(Media.Category[i].Marker) + 1]; + CopyString(SanitisedMarker, sizeof(SanitisedMarker), "%s", Media.Category[i].Marker); SanitisePunctuation(SanitisedMarker); int j; @@ -4066,14 +4063,14 @@ AppendedIdentifier: "

In-Menu Movement

\n" "
\n" "
\n" - "
\n" + "
\n" " a\n" "
\n" - "
\n" + "
\n" " w
\n" " s\n" "
\n" - "
\n" + "
\n" " d\n" "
\n" "
\n" @@ -4084,14 +4081,14 @@ AppendedIdentifier: " l\n" "
\n" "
\n" - "
\n" + "
\n" " \n" "
\n" - "
\n" + "
\n" "
\n" " \n" "
\n" - "
\n" + "
\n" " \n" "
\n" "
\n" @@ -4128,12 +4125,12 @@ AppendedIdentifier: if(HasQuoteMenu || HasReferenceMenu) { CopyStringToBuffer(&CollationBuffers->Menus, - " Enter Jump to timecode
\n"); + " Enter Jump to timecode
\n"); } else { CopyStringToBuffer(&CollationBuffers->Menus, - " Enter Jump to timecode
\n"); + " Enter Jump to timecode
\n"); } CopyStringToBuffer(&CollationBuffers->Menus, "\n"); @@ -4217,16 +4214,16 @@ AppendedIdentifier: { CopyStringToBuffer(&CollationBuffers->Menus, "

Filter Menu

\n" - " x, Space Toggle category and focus next
\n" - " X, ShiftSpace Toggle category and focus previous
\n" + " x, Space Toggle category and focus next
\n" + " X, ShiftSpace Toggle category and focus previous
\n" " v Invert topics / media as per focus\n"); } else { CopyStringToBuffer(&CollationBuffers->Menus, "

Filter Menu

\n" - " x, Space Toggle category and focus next
\n" - " X, ShiftSpace Toggle category and focus previous
\n" + " x, Space Toggle category and focus next
\n" + " X, ShiftSpace Toggle category and focus previous
\n" " v Invert topics / media as per focus\n"); } @@ -4236,13 +4233,13 @@ AppendedIdentifier: { CopyStringToBuffer(&CollationBuffers->Menus, "

Credits Menu

\n" - " Enter Open URL (in new tab)
\n"); + " Enter Open URL (in new tab)
\n"); } else { CopyStringToBuffer(&CollationBuffers->Menus, "

Credits Menu

\n" - " Enter Open URL (in new tab)
\n"); + " Enter Open URL (in new tab)
\n"); } CopyStringToBuffer(&CollationBuffers->Menus, @@ -4290,40 +4287,30 @@ AppendedIdentifier: buffer URLIndex; ClaimBuffer(&URLIndex, "URLIndex", MAX_BASE_URL_LENGTH + 1 + MAX_RELATIVE_PAGE_LOCATION_LENGTH + 1); ConstructIndexURL(&URLIndex); - CopyString(CollationBuffers->URLIndex, URLIndex.Location); + CopyString(CollationBuffers->URLIndex, sizeof(CollationBuffers->URLIndex), "%s", URLIndex.Location); DeclaimBuffer(&URLIndex); buffer URLPrefix; ClaimBuffer(&URLPrefix, "URLPrefix", 1024); ConstructURLPrefix(&URLPrefix, INCLUDE_CSS, PAGE_INDEX); CopyStringToBuffer(&CollationBuffers->IncludesIndex, - "\n" - " \n" - " \n" - " \n" + "\n" + " \n" "\n" - " \n" - " \n", - URLPrefix.Location, - URLPrefix.Location, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project, - URLPrefix.Location, - + " \n" + " \n" + " \n", CINERA_APP_VERSION.Major, CINERA_APP_VERSION.Minor, - CINERA_APP_VERSION.Patch); + CINERA_APP_VERSION.Patch, - ConstructURLPrefix(&URLPrefix, INCLUDE_CSS, PAGE_PLAYER); - CopyStringToBuffer(&CollationBuffers->IncludesPlayer, - "\n" - " \n" - " \n" - "\n" - " \n" - " \n", URLPrefix.Location, URLPrefix.Location, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project, - URLPrefix.Location, + URLPrefix.Location); + CopyStringToBuffer(&CollationBuffers->IncludesPlayer, + "\n" + " \n", CINERA_APP_VERSION.Major, CINERA_APP_VERSION.Minor, CINERA_APP_VERSION.Patch); @@ -4356,23 +4343,27 @@ AppendedIdentifier: CopyStringToBuffer(&CollationBuffers->IncludesPlayer, "\">\n\n"); } + ConstructURLPrefix(&URLPrefix, INCLUDE_CSS, PAGE_PLAYER); + CopyStringToBuffer(&CollationBuffers->IncludesPlayer, + "\n" + " \n" + " \n" + " \n", + URLPrefix.Location, + URLPrefix.Location, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project, + URLPrefix.Location); + ConstructURLPrefix(&URLPrefix, INCLUDE_JS, PAGE_PLAYER); CopyStringToBuffer(&CollationBuffers->IncludesPlayer, " ", URLPrefix.Location); - if(HasFilterMenu) - { - CopyBuffer(&CollationBuffers->ScriptPlayer, &FilterState); - } - CopyStringToBuffer(&CollationBuffers->ScriptPlayer, - " ", + "", URLPrefix.Location); DeclaimBuffer(&URLPrefix); // NOTE(matt): Tree structure of "global" buffer dependencies - // FilterState // CreditsMenu // FilterMedia // FilterTopics @@ -4380,8 +4371,6 @@ AppendedIdentifier: // ReferenceMenu // QuoteMenu - DeclaimBuffer(&FilterState); - DeclaimBuffer(&CreditsMenu); DeclaimBuffer(&FilterMedia); DeclaimBuffer(&FilterTopics); @@ -4414,9 +4403,9 @@ BuffersToHTML(buffers *CollationBuffers, template *Template, char *OutputPath, i fclose(MemLog); #endif - if(Template->Metadata.Filename && StringsDiffer(Template->Metadata.Filename, "")) + if(StringsDiffer(Template->Metadata.Filename, "")) { - if((Template->Metadata.Filename && StringsDiffer(Template->Metadata.Filename, "")) + if((StringsDiffer(Template->Metadata.Filename, "")) && ((Template->Metadata.Validity & PageType) || Config.Mode & MODE_FORCEINTEGRATION)) { buffer Output; @@ -4662,6 +4651,7 @@ AccumulateIndexEntryInsertionOffset(index *Index, int EntryIndex) index_metadata *AccEntry = { 0 }; if(EntryIndex < Index->Header.EntryCount >> 1) { + //printf("\u200B"); // NOTE(matt): Don't ask... for(; EntryIndex > 0; --EntryIndex) { AccEntry = (index_metadata*)(Index->Metadata.Buffer.Location + sizeof(index_header) + sizeof(index_metadata) * (EntryIndex - 1)); @@ -4703,7 +4693,7 @@ enum void GetNeighbourhood(index *Index, neighbourhood *N, int IndexEditType, bool *ThisIsPrev) { - index_metadata Entry = { 0 }; + index_metadata Entry = { }; int EntryIndex; int IncomingIndex = N->ThisIndex; @@ -4742,8 +4732,8 @@ GetNeighbourhood(index *Index, neighbourhood *N, int IndexEditType, bool *ThisIs N->This.LinkOffsets.PrevEnd = Entry.LinkOffsets.PrevEnd; N->This.LinkOffsets.NextStart = Entry.LinkOffsets.NextStart; N->This.LinkOffsets.NextEnd = Entry.LinkOffsets.NextEnd; - CopyString(N->This.BaseFilename, Entry.BaseFilename); - CopyString(N->This.Title, Entry.Title); + CopyString(N->This.BaseFilename, sizeof(N->This.BaseFilename), "%s", Entry.BaseFilename); + CopyString(N->This.Title, sizeof(N->This.Title), "%s", Entry.Title); } else { @@ -4776,8 +4766,8 @@ GetNeighbourhood(index *Index, neighbourhood *N, int IndexEditType, bool *ThisIs N->Prev.LinkOffsets.PrevEnd = Entry.LinkOffsets.PrevEnd; N->Prev.LinkOffsets.NextStart = Entry.LinkOffsets.NextStart; N->Prev.LinkOffsets.NextEnd = Entry.LinkOffsets.NextEnd; - CopyString(N->Prev.BaseFilename, Entry.BaseFilename); - CopyString(N->Prev.Title, Entry.Title); + CopyString(N->Prev.BaseFilename, sizeof(N->Prev.BaseFilename), "%s", Entry.BaseFilename); + CopyString(N->Prev.Title, sizeof(N->Prev.Title), "%s", Entry.Title); FoundPrev = TRUE; } else @@ -4814,8 +4804,8 @@ GetNeighbourhood(index *Index, neighbourhood *N, int IndexEditType, bool *ThisIs N->Next.LinkOffsets.PrevEnd = Entry.LinkOffsets.PrevEnd; N->Next.LinkOffsets.NextStart = Entry.LinkOffsets.NextStart; N->Next.LinkOffsets.NextEnd = Entry.LinkOffsets.NextEnd; - CopyString(N->Next.BaseFilename, Entry.BaseFilename); - CopyString(N->Next.Title, Entry.Title); + CopyString(N->Next.BaseFilename, sizeof(N->Next.BaseFilename), "%s", Entry.BaseFilename); + CopyString(N->Next.Title, sizeof(N->Next.Title), "%s", Entry.Title); FoundNext = TRUE; } else @@ -4892,14 +4882,13 @@ InsertIntoIndex(index *Index, neighbourhood *N, buffers *CollationBuffers, templ { // Reinsert Reinserting = TRUE; - N->This.Size = Entry->Size; N->This.LinkOffsets.PrevStart = Entry->LinkOffsets.PrevStart; N->This.LinkOffsets.PrevEnd = Entry->LinkOffsets.PrevEnd; N->This.LinkOffsets.NextStart = Entry->LinkOffsets.NextStart; N->This.LinkOffsets.NextEnd = Entry->LinkOffsets.NextEnd; IndexEntryInsertionStart = AccumulateIndexEntryInsertionOffset(Index, N->ThisIndex); - IndexEntryInsertionEnd = IndexEntryInsertionStart + N->This.Size; + IndexEntryInsertionEnd = IndexEntryInsertionStart + Entry->Size; } else { @@ -4934,21 +4923,21 @@ InsertIntoIndex(index *Index, neighbourhood *N, buffers *CollationBuffers, templ Index->Header.InitialHMMLVersion.Minor = hmml_version.Minor; Index->Header.InitialHMMLVersion.Patch = hmml_version.Patch; - CopyStringNoFormat(Index->Header.ProjectID, Config.ProjectID); + CopyStringNoFormat(Index->Header.ProjectID, sizeof(Index->Header.ProjectID), Config.ProjectID); for(int ProjectIndex = 0; ProjectIndex < ArrayCount(ProjectInfo); ++ProjectIndex) { if(!StringsDiffer(ProjectInfo[ProjectIndex].ProjectID, Config.ProjectID)) { - CopyStringNoFormat(Index->Header.ProjectName, ProjectInfo[ProjectIndex].FullName); + CopyStringNoFormat(Index->Header.ProjectName, sizeof(Index->Header.ProjectName), ProjectInfo[ProjectIndex].FullName); break; } } - CopyStringNoFormat(Index->Header.BaseURL, Config.BaseURL); - CopyStringNoFormat(Index->Header.IndexLocation, Config.IndexLocation); - CopyStringNoFormat(Index->Header.PlayerLocation, Config.PlayerLocation); - CopyStringNoFormat(Index->Header.PlayerURLPrefix, Config.PlayerURLPrefix); + CopyStringNoFormat(Index->Header.BaseURL, sizeof(Index->Header.BaseURL), Config.BaseURL); + CopyStringNoFormat(Index->Header.IndexLocation, sizeof(Index->Header.IndexLocation), Config.IndexLocation); + CopyStringNoFormat(Index->Header.PlayerLocation, sizeof(Index->Header.PlayerLocation), Config.PlayerLocation); + CopyStringNoFormat(Index->Header.PlayerURLPrefix, sizeof(Index->Header.PlayerURLPrefix), Config.PlayerURLPrefix); DIR *OutputDirectoryHandle; if(!(OutputDirectoryHandle = opendir(Config.BaseDir))) @@ -4963,8 +4952,8 @@ InsertIntoIndex(index *Index, neighbourhood *N, buffers *CollationBuffers, templ closedir(OutputDirectoryHandle); } - char InputFile[StringLength(BaseFilename) + StringLength(".hmml")]; - CopyString(InputFile, "%s.hmml", BaseFilename); + char InputFile[StringLength(BaseFilename) + StringLength(".hmml") + 1]; + CopyString(InputFile, sizeof(InputFile), "%s.hmml", BaseFilename); bool VideoIsPrivate = FALSE; switch(HMMLToBuffers(CollationBuffers, BespokeTemplate, InputFile, N)) @@ -5104,7 +5093,7 @@ void ConstructDirectoryPath(buffer *DirectoryPath, int PageType, char *PageLocation, char *BaseFilename) { RewindBuffer(DirectoryPath); - CopyStringToBuffer(DirectoryPath, Config.BaseDir); + CopyStringToBuffer(DirectoryPath, "%s", Config.BaseDir); switch(PageType) { case PAGE_INDEX: @@ -5311,7 +5300,7 @@ LinkNeighbours(index *Index, neighbourhood *N, char *BaseFilename, int LinkType) CopyStringToBuffer(&LonePlayerPagePath, "/index.html"); file_buffer LonePlayerPage; - CopyStringNoFormat(LonePlayerPage.Path, LonePlayerPagePath.Location); + CopyStringNoFormat(LonePlayerPage.Path, sizeof(LonePlayerPage.Path), LonePlayerPagePath.Location); DeleteNeighbourLinks(&LonePlayerPage, &N->This); DeclaimBuffer(&LonePlayerPagePath); @@ -5329,7 +5318,7 @@ LinkNeighbours(index *Index, neighbourhood *N, char *BaseFilename, int LinkType) CopyStringToBuffer(&PreviousPlayerPagePath, "/index.html"); file_buffer PreviousPlayerPage; - CopyStringNoFormat(PreviousPlayerPage.Path, PreviousPlayerPagePath.Location); + CopyStringNoFormat(PreviousPlayerPage.Path, sizeof(PreviousPlayerPage.Path), PreviousPlayerPagePath.Location); switch(LinkType) { @@ -5341,7 +5330,7 @@ LinkNeighbours(index *Index, neighbourhood *N, char *BaseFilename, int LinkType) CopyStringToBuffer(&ThisPlayerPagePath, "/index.html"); file_buffer ThisPlayerPage; - CopyStringNoFormat(ThisPlayerPage.Path, ThisPlayerPagePath.Location); + CopyStringNoFormat(ThisPlayerPage.Path, sizeof(ThisPlayerPage.Path), ThisPlayerPagePath.Location); InsertNeighbourLink(&ThisPlayerPage, &N->This, &N->Prev, LINK_PREV, Index->Header.ProjectName, N->NextIndex == -1 ? TRUE : FALSE); @@ -5369,7 +5358,7 @@ LinkNeighbours(index *Index, neighbourhood *N, char *BaseFilename, int LinkType) CopyStringToBuffer(&NextPlayerPagePath, "/index.html"); file_buffer NextPlayerPage; - CopyStringNoFormat(NextPlayerPage.Path, NextPlayerPagePath.Location); + CopyStringNoFormat(NextPlayerPage.Path, sizeof(NextPlayerPage.Path), NextPlayerPagePath.Location); switch(LinkType) { @@ -5381,7 +5370,7 @@ LinkNeighbours(index *Index, neighbourhood *N, char *BaseFilename, int LinkType) CopyStringToBuffer(&ThisPlayerPagePath, "/index.html"); file_buffer ThisPlayerPage; - CopyStringNoFormat(ThisPlayerPage.Path, ThisPlayerPagePath.Location); + CopyStringNoFormat(ThisPlayerPage.Path, sizeof(ThisPlayerPage.Path), ThisPlayerPagePath.Location); InsertNeighbourLink(&ThisPlayerPage, &N->This, &N->Next, LINK_NEXT, Index->Header.ProjectName, N->PrevIndex == -1 ? TRUE : FALSE); @@ -5418,7 +5407,7 @@ DeleteIndexPageFromFilesystem() // NOTE(matt): Do we need to handle relocating, ClaimBuffer(&IndexDirectory, "IndexDirectory", 1024); ConstructDirectoryPath(&IndexDirectory, PAGE_INDEX, Config.IndexLocation, ""); char IndexPagePath[1024]; - CopyString(IndexPagePath, "%s/index.html", IndexDirectory.Location); + CopyString(IndexPagePath, sizeof(IndexPagePath), "%s/index.html", IndexDirectory.Location); remove(IndexPagePath); remove(IndexDirectory.Location); DeclaimBuffer(&IndexDirectory); @@ -5436,7 +5425,7 @@ DeletePlayerPageFromFilesystem(char *BaseFilename, char *PlayerLocation, bool Re if((PlayerDir = opendir(OutputDirectoryPath.Location))) // There is a directory for the Player, which there probably should be if not for manual intervention { char PlayerPagePath[256]; - CopyString(PlayerPagePath, "%s/index.html", OutputDirectoryPath.Location); + CopyString(PlayerPagePath, sizeof(PlayerPagePath), "%s/index.html", OutputDirectoryPath.Location); FILE *PlayerPage; if((PlayerPage = fopen(PlayerPagePath, "r"))) { @@ -5560,9 +5549,9 @@ IndexToBuffer(index *Index, buffers *CollationBuffers) // NOTE(matt): This guy m } char *Theme = StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID; - int ThemeStringAllowance = StringLength(Theme) * 2; - char queryContainer[680 + ThemeStringAllowance]; - CopyString(queryContainer, + 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 + CopyString(queryContainer, sizeof(queryContainer), "
\n" " \n" "
\n" @@ -5575,42 +5564,39 @@ IndexToBuffer(index *Index, buffers *CollationBuffers) // NOTE(matt): This guy m "
Found: 0 episodes, 0 markers, 0h 0m 0s total.
\n" "
\n" "\n" - "
\n" + "
\n" "
Sort: Old to New ⏶
\n" "
\n", Theme, - Theme); - - buffer PlayerURL; - ClaimBuffer(&PlayerURL, "PlayerURL", MAX_BASE_URL_LENGTH + 1 + MAX_RELATIVE_PAGE_LOCATION_LENGTH + 1 + MAX_PLAYER_URL_PREFIX_LENGTH + MAX_BASE_FILENAME_LENGTH); - ConstructPlayerURL(&PlayerURL, ""); + Theme, + Config.ProjectID, + Config.BaseURL, + Config.PlayerLocation); buffer URLPrefix; ClaimBuffer(&URLPrefix, "URLPrefix", 1024); ConstructURLPrefix(&URLPrefix, INCLUDE_JS, PAGE_INDEX); - char Script[532 + StringLength(URLPrefix.Location) + (StringLength(Config.ProjectID) * 2)]; - CopyString(Script, + char Script[107 + StringLength(URLPrefix.Location)]; // NOTE(matt): Update the size if changing the string + CopyString(Script, sizeof(Script), "
\n" "
\n" - " \n" " \n", - Config.ProjectID, - Theme, - Config.BaseURL, - Config.PlayerLocation, - StringsDiffer(Config.PlayerURLPrefix, "") ? Config.PlayerURLPrefix : Config.ProjectID, URLPrefix.Location); DeclaimBuffer(&URLPrefix); - int EntryLength = 32 + StringLength(ProjectInfo[ProjectIndex].Unit) + 16 + 256; + buffer PlayerURL; + ClaimBuffer(&PlayerURL, "PlayerURL", MAX_BASE_URL_LENGTH + 1 + MAX_RELATIVE_PAGE_LOCATION_LENGTH + 1 + MAX_PLAYER_URL_PREFIX_LENGTH + MAX_BASE_FILENAME_LENGTH); + ConstructPlayerURL(&PlayerURL, ""); + char *ProjectUnit = 0; + if(StringsDiffer(ProjectInfo[ProjectIndex].Unit, "")) + { + ProjectUnit = ProjectInfo[ProjectIndex].Unit; + } + char Number[16]; + index_metadata *This; + char Text[StringLength(ProjectUnit) + sizeof(Number) + sizeof(This->Title) + 3]; + int EntryLength = StringLength(PlayerURL.Location) + sizeof(Text) + 82; CollationBuffers->Index.Size = StringLength(queryContainer) + (Index->Header.EntryCount * EntryLength) + StringLength(Script); if(!(CollationBuffers->Index.Location = malloc(CollationBuffers->Index.Size))) @@ -5621,17 +5607,9 @@ IndexToBuffer(index *Index, buffers *CollationBuffers) // NOTE(matt): This guy m CollationBuffers->Index.ID = "Index"; CollationBuffers->Index.Ptr = CollationBuffers->Index.Location; - CopyStringToBuffer(&CollationBuffers->Index, queryContainer); + CopyStringToBuffer(&CollationBuffers->Index, "%s", queryContainer); - char *ProjectUnit = 0; - if(StringsDiffer(ProjectInfo[ProjectIndex].Unit, "")) - { - ProjectUnit = ProjectInfo[ProjectIndex].Unit; - } int ProjectIDLength = StringLength(Config.ProjectID); - char Number[16]; - char Text[1024]; // NOTE(matt): Surely this will be big enough - index_metadata *This; bool IndexRequired = FALSE; for(int EntryIndex = 0; EntryIndex < Index->Header.EntryCount; ++EntryIndex, Index->Metadata.Buffer.Ptr += sizeof(index_metadata)) @@ -5640,7 +5618,7 @@ IndexToBuffer(index *Index, buffers *CollationBuffers) // NOTE(matt): This guy m if(This->Size > 0) { IndexRequired = TRUE; - CopyString(Number, This->BaseFilename + ProjectIDLength); + CopyString(Number, sizeof(Number), "%s", This->BaseFilename + ProjectIDLength); if(ProjectInfo[ProjectIndex].NumberingScheme == NS_LINEAR) { for(int i = 0; Number[i]; ++i) @@ -5660,7 +5638,7 @@ IndexToBuffer(index *Index, buffers *CollationBuffers) // NOTE(matt): This guy m "
\n" " ", PlayerURL.Location); - CopyString(Text, "%s %s: %s", + CopyString(Text, sizeof(Text), "%s %s: %s", ProjectUnit, // TODO(matt): Do we need to special-case the various numbering schemes? Number, This->Title); @@ -5687,7 +5665,7 @@ IndexToBuffer(index *Index, buffers *CollationBuffers) // NOTE(matt): This guy m DeclaimBuffer(&PlayerURL); - CopyStringToBuffer(&CollationBuffers->Index, Script); + CopyStringToBuffer(&CollationBuffers->Index, "%s", Script); FreeBuffer(&Index->Metadata.Buffer); if(!IndexRequired) { return RC_NOOP; } @@ -5751,7 +5729,7 @@ GeneratePlayerPage(index *Index, neighbourhood *N, buffers *CollationBuffers, te closedir(OutputDirectoryHandle); char PlayerPagePath[1024]; - CopyString(PlayerPagePath, "%s/index.html", OutputDirectoryPath.Location); + CopyString(PlayerPagePath, sizeof(PlayerPagePath), "%s/index.html", OutputDirectoryPath.Location); DeclaimBuffer(&OutputDirectoryPath); bool IndexInTemplate = FALSE; @@ -5802,7 +5780,7 @@ GenerateIndexPage(index *Index, buffers *CollationBuffers, template *IndexTempla closedir(OutputDirectoryHandle); char IndexPagePath[1024]; - CopyString(IndexPagePath, "%s/index.html", OutputDirectoryPath.Location); + CopyString(IndexPagePath, sizeof(IndexPagePath), "%s/index.html", OutputDirectoryPath.Location); DeclaimBuffer(&OutputDirectoryPath); switch(IndexToBuffer(Index, CollationBuffers)) { @@ -5846,7 +5824,7 @@ InsertEntry(index *Index, neighbourhood *Neighbourhood, buffers *CollationBuffer *Inserted = TRUE; case RC_SUCCESS: { - if(BespokeTemplate->Metadata.Filename && StringsDiffer(BespokeTemplate->Metadata.Filename, "")) + if(StringsDiffer(BespokeTemplate->Metadata.Filename, "")) { GeneratePlayerPage(Index, Neighbourhood, CollationBuffers, BespokeTemplate, BaseFilename); DeclaimTemplate(BespokeTemplate); @@ -5866,7 +5844,7 @@ RecheckPrivacy(index *Index, buffers *CollationBuffers, template *IndexTemplate, if(ReadFileIntoBuffer(&Index->Metadata, 0) == RC_SUCCESS) { Index->Header = *(index_header*)Index->Metadata.Buffer.Ptr; - index_metadata Entry = { 0 }; + index_metadata Entry = { }; int PrivateEntryIndex = 0; index_metadata PrivateEntries[Index->Header.EntryCount]; bool Inserted = FALSE; @@ -5883,7 +5861,7 @@ RecheckPrivacy(index *Index, buffers *CollationBuffers, template *IndexTemplate, for(int i = 0; i < PrivateEntryIndex; ++i) { - neighbourhood Neighbourhood = { 0 }; + neighbourhood Neighbourhood = { }; Neighbourhood.PrevIndex = -1; Neighbourhood.ThisIndex = -1; Neighbourhood.NextIndex = -1; @@ -5930,7 +5908,7 @@ MonitorDirectory(index *Index, buffers *CollationBuffers, template *IndexTemplat if(!(StringsDiffer(Ptr, ".hmml"))) { *Ptr = '\0'; - neighbourhood Neighbourhood = { 0 }; + neighbourhood Neighbourhood = { }; Neighbourhood.PrevIndex = -1; Neighbourhood.ThisIndex = -1; Neighbourhood.NextIndex = -1; @@ -6013,8 +5991,8 @@ UpgradeDB(index *Index) bool OnlyHeaderChanged = TRUE; int OriginalHeaderSize = 0; - index1 Index1 = { 0 }; - index2 Index2 = { 0 }; + index1 Index1 = { }; + index2 Index2 = { }; int OriginalDBVersion = Index->Header.CurrentDBVersion; switch(OriginalDBVersion) @@ -6063,7 +6041,7 @@ UpgradeDB(index *Index) { if(!StringsDiffer(ProjectInfo[ProjectIndex].ProjectID, Config.ProjectID)) { - CopyString(Index->Header.ProjectName, ProjectInfo[ProjectIndex].FullName); + CopyString(Index->Header.ProjectName, sizeof(Index->Header.ProjectName), "%s", ProjectInfo[ProjectIndex].FullName); break; } } @@ -6109,7 +6087,7 @@ UpgradeDB(index *Index) char *IndexEntryStart = Index->File.Buffer.Ptr; SeekBufferForString(&Index->File.Buffer, "title: \"", C_SEEK_FORWARDS, C_SEEK_AFTER); Clear(Index->Entry.Title, sizeof(Index->Entry.Title)); - CopyStringNoFormatT(Index->Entry.Title, Index->File.Buffer.Ptr, '\n'); + CopyStringNoFormatT(Index->Entry.Title, sizeof(Index->Entry.Title), Index->File.Buffer.Ptr, '\n'); Index->Entry.Title[StringLength(Index->Entry.Title) - 1] = '\0'; fwrite(&Index->Entry, sizeof(Index->Entry), 1, Index->Metadata.Handle); @@ -6247,7 +6225,7 @@ DeleteDeadIndexEntries(index *Index) DeclaimBuffer(&NewIndexDirectory); char IndexPagePath[2048] = { 0 }; - CopyString(IndexPagePath, "%s/index.html", OldIndexDirectory.Location); + CopyString(IndexPagePath, sizeof(IndexPagePath), "%s/index.html", OldIndexDirectory.Location); remove(IndexPagePath); if(StringLength(Index->Header.IndexLocation) > 0) { @@ -6272,7 +6250,7 @@ DeleteDeadIndexEntries(index *Index) for(int EntryIndex = 0; EntryIndex < Index->Header.EntryCount; ++EntryIndex) { index_metadata This = *(index_metadata *)(Index->Metadata.Buffer.Location + sizeof(index_header) + sizeof(index_metadata) * EntryIndex); - CopyStringNoFormat(Entries[EntryIndex].ID, This.BaseFilename); + CopyStringNoFormat(Entries[EntryIndex].ID, sizeof(Entries[EntryIndex].ID), This.BaseFilename); Entries[EntryIndex].Present = FALSE; } @@ -6312,7 +6290,7 @@ DeleteDeadIndexEntries(index *Index) if(Entries[i].Present == FALSE) { Deleted = TRUE; - neighbourhood Neighbourhood = { 0 }; + neighbourhood Neighbourhood = { }; Neighbourhood.PrevIndex = -1; Neighbourhood.ThisIndex = -1; Neighbourhood.NextIndex = -1; @@ -6351,7 +6329,7 @@ SyncIndexWithInput(index *Index, buffers *CollationBuffers, template *IndexTempl if(!(StringsDiffer(Ptr, ".hmml"))) { *Ptr = '\0'; - neighbourhood Neighbourhood = { 0 }; + neighbourhood Neighbourhood = { }; Neighbourhood.PrevIndex = -1; Neighbourhood.NextIndex = -1; InsertEntry(Index, &Neighbourhood, CollationBuffers, PlayerTemplate, BespokeTemplate, ProjectFiles->d_name, &Inserted, 0); @@ -6412,11 +6390,11 @@ main(int ArgC, char **Args) if(getenv("XDG_CACHE_HOME")) { - CopyString(DefaultConfig.CacheDir, "%s/cinera", getenv("XDG_CACHE_HOME")); + CopyString(DefaultConfig.CacheDir, sizeof(DefaultConfig.CacheDir), "%s/cinera", getenv("XDG_CACHE_HOME")); } else { - CopyString(DefaultConfig.CacheDir, "%s/.cache/cinera", getenv("HOME")); + CopyString(DefaultConfig.CacheDir, sizeof(DefaultConfig.CacheDir), "%s/.cache/cinera", getenv("HOME")); } Config = DefaultConfig; @@ -6518,10 +6496,10 @@ main(int ArgC, char **Args) if(Config.Mode & MODE_EXAMINE) { - index Index = { 0 }; + index Index = { }; Index.Metadata.Buffer.ID = "IndexMetadata"; // TODO(matt): Allow optionally passing a .metadata file as an argument? - CopyString(Index.Metadata.Path, "%s/%s.metadata", Config.BaseDir, Config.ProjectID); + CopyString(Index.Metadata.Path, sizeof(Index.Metadata.Path), "%s/%s.metadata", Config.BaseDir, Config.ProjectID); ExamineIndex(&Index); exit(RC_SUCCESS); } @@ -6759,11 +6737,11 @@ main(int ArgC, char **Args) return(RC_SUCCESS); } - index Index = { 0 }; + index Index = { }; Index.Metadata.Buffer.ID = "IndexMetadata"; - CopyString(Index.Metadata.Path, "%s/%s.metadata", Config.BaseDir, Config.ProjectID); + CopyString(Index.Metadata.Path, sizeof(Index.Metadata.Path), "%s/%s.metadata", Config.BaseDir, Config.ProjectID); Index.File.Buffer.ID = "IndexFile"; - CopyString(Index.File.Path, "%s/%s.index", Config.BaseDir, Config.ProjectID); + CopyString(Index.File.Path, sizeof(Index.File.Path), "%s/%s.index", Config.BaseDir, Config.ProjectID); printf("┌╼ Synchronising with annotation files in Project Input Directory ╾┐\n"); SyncIndexWithInput(&Index, &CollationBuffers, IndexTemplate, PlayerTemplate, BespokeTemplate); @@ -6814,7 +6792,7 @@ NextFile: Ptr += (StringLength(Args[FileIndex]) - StringLength(".hmml")); if(!(StringsDiffer(Ptr, ".hmml"))) { - CopyString(Config.SingleHMMLFilePath, Args[FileIndex]); + CopyString(Config.SingleHMMLFilePath, sizeof(Config.SingleHMMLFilePath), "%s", Args[FileIndex]); switch(HMMLToBuffers(&CollationBuffers, &BespokeTemplate, Args[FileIndex], 0)) { // TODO(matt): Actually sort out the fatality of these cases, once we are always-on diff --git a/cinera/cinera.css b/cinera/cinera.css index fed5531..a36ecae 100644 --- a/cinera/cinera.css +++ b/cinera/cinera.css @@ -166,6 +166,14 @@ margin: 2px; } +.cineraMenus .help .help_container .help_key.word { + width: auto; +} + +.cineraMenus .help .help_container .help_key.modifer { + margin-right: 0; +} + .cineraMenus .help .help_container .help_key.unavailable, .cineraMenus .help .help_container .help_text.unavailable, .cineraMenus .help .help_container h2 .unavailable { @@ -544,6 +552,7 @@ .cineraPlayerContainer .markers_container > .markers .marker .cineraContent sup { font-style: normal; font-variant: normal; + vertical-align: super; } .cineraPlayerContainer .markers_container > .markers .marker .progress { diff --git a/cinera/cinera_player_post.js b/cinera/cinera_player_post.js index 185ce26..533c3b3 100644 --- a/cinera/cinera_player_post.js +++ b/cinera/cinera_player_post.js @@ -83,6 +83,9 @@ if(filterMenu) var filterMode = filterModeElement.classList[1]; var filterItems = filter.querySelectorAll(".filter_content"); + + var filterInitState = new Object(); + var filterState = new Object(); for(var i = 0; i < filterItems.length; ++i) { filterItems[i].addEventListener("mouseenter", function(ev) { @@ -92,6 +95,18 @@ if(filterMenu) filterItems[i].addEventListener("click", function(ev) { filterItemToggle(this); }); + + var filterItemName = filterItems[i].classList.item(1); + if(filterItems[i].parentNode.classList.contains("filter_topics")) + { + filterInitState[filterItemName] = { "type" : "topic", "off": (filterItems[i].classList.item(2) == "off") }; + filterState[filterItemName] = { "type" : "topic", "off": (filterItems[i].classList.item(2) == "off") }; + } + else + { + filterInitState[filterItemName] = { "type" : "medium", "off": (filterItems[i].classList.item(2) == "off") }; + filterState[filterItemName] = { "type" : "medium", "off": (filterItems[i].classList.item(2) == "off") }; + } } } @@ -176,6 +191,7 @@ if(creditsMenu) { for(var i = 0; i < supportIcons.length; ++i) { + supportIcons[i].style.backgroundImage = "url(\"" + supportIcons[i].getAttribute("data-sprite") + "\")"; setIconLightness(supportIcons[i]); } } diff --git a/cinera/cinera_player_pre.js b/cinera/cinera_player_pre.js index 0ea4cf6..6caa3a5 100644 --- a/cinera/cinera_player_pre.js +++ b/cinera/cinera_player_pre.js @@ -1190,7 +1190,6 @@ function resetFade() { function onRefChanged(ref, element, player) { if(element.classList.contains("skip")) { - var filterState; var ErrorCount = 0; if(!filter) { console.log("Missing filter_container div"); ErrorCount++; } if(!filterState) { console.log("Missing filterState object"); ErrorCount++; } diff --git a/cinera/cinera_search.js b/cinera/cinera_search.js index a0828be..6612d46 100644 --- a/cinera/cinera_search.js +++ b/cinera/cinera_search.js @@ -1,3 +1,5 @@ +document.body.style.overflowY = "scroll"; + if (location.hash && location.hash.length > 0) { var initialQuery = location.hash; if (initialQuery[0] == "#") { @@ -7,6 +9,11 @@ if (location.hash && location.hash.length > 0) { } var indexContainer = document.getElementById("cineraIndex"); +var projectID = indexContainer.attributes.getNamedItem("data-project").value; +var theme = indexContainer.classList.item(0); +var baseURL = indexContainer.attributes.getNamedItem("data-baseURL").value; +var playerLocation = indexContainer.attributes.getNamedItem("data-playerLocation").value; + var indexSort = indexContainer.querySelector("#cineraIndexSort"); var indexEntries = indexContainer.querySelector("#cineraIndexEntries"); var indexSortChronological = true; @@ -224,12 +231,7 @@ xhr.addEventListener("load", function() { episode = {}; mode = "none"; } else if (line.startsWith("name:")) { - if(projectID != outputURLPrefix) { - episode.name = line.slice(6).replace(projectID, outputURLPrefix); - } - else { - episode.name = line.slice(6); - } + episode.name = line.slice(6); } else if (line.startsWith("title:")) { episode.title = line.slice(7).replace(/"/g, ""); } else if (line.startsWith("markers")) {