diff --git a/Makefile b/Makefile
index 53bff45..f302aba 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qu
LDFLAGS = -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcurl libpcre2-8) -lfcgi
SRC = $(wildcard src/*.c)
OBJ = $(patsubst %.c,%.o,$(SRC))
-HEADERS = $(wildcard src/*.h)
+HEADERS = $(wildcard src/*.h) config.h
PAGES_DIR = static
PAGES = $(wildcard $(PAGES_DIR)/*.tmpl)
PAGES_CMP = $(patsubst %.tmpl,%.ctmpl,$(PAGES))
diff --git a/dist/treebird20.css b/dist/treebird20.css
index 5235a3c..ad5a056 100644
--- a/dist/treebird20.css
+++ b/dist/treebird20.css
@@ -1191,6 +1191,11 @@ p}
min-width: 25px !important;
}
+.notification-compact .status-interact .statbtn
+{
+ min-width: 0px !important;
+}
+
.active-anim
{
animation: interact .7s 1;
diff --git a/src/status.c b/src/status.c
index 5868505..88f576f 100644
--- a/src/status.c
+++ b/src/status.c
@@ -416,14 +416,16 @@ char* reformat_status(struct session* ssn,
return res;
}
-#define REGEX_MENTION ""
+#define REGEX_MENTION ""
char* make_mentions_local(char* content)
{
char* url_format;
int error;
PCRE2_SIZE erroffset;
- size_t res_len = 512;
+ // Initial size, will be increased by 30% if pcre2_substitute cannot fit into the size
+ // ...why can't pcre2 just allocate a string with the size for us? Thanks...
+ size_t res_len = 1024;
char* res = malloc(res_len);
pcre2_code* re = pcre2_compile((PCRE2_SPTR)REGEX_MENTION,
PCRE2_ZERO_TERMINATED, 0,
@@ -436,25 +438,46 @@ char* make_mentions_local(char* content)
}
int len = easprintf(&url_format,
- "",
+ "",
config_host_url_insecure ? "" : "s",
getenv("HTTP_HOST"));
- int amt = pcre2_substitute(re,
- (PCRE2_SPTR)content,
- PCRE2_ZERO_TERMINATED,
- 0,
- PCRE2_SUBSTITUTE_EXTENDED | PCRE2_SUBSTITUTE_GLOBAL,
- NULL,
- NULL,
- (PCRE2_SPTR)url_format,
- len,
- (PCRE2_UCHAR*)res,
- &res_len);
-
+ int rc = -1;
+ PCRE2_SIZE res_len_str;
+ while (rc < 0)
+ {
+ res_len_str = res_len;
+ rc = pcre2_substitute(
+ re,
+ (PCRE2_SPTR)content,
+ PCRE2_ZERO_TERMINATED,
+ 0,
+ PCRE2_SUBSTITUTE_EXTENDED | PCRE2_SUBSTITUTE_GLOBAL,
+ NULL,
+ NULL,
+ (PCRE2_SPTR)url_format,
+ len,
+ (PCRE2_UCHAR*)res,
+ &res_len_str
+ );
+ if (rc < 0)
+ {
+ switch (rc)
+ {
+ case PCRE2_ERROR_NOMEMORY:
+ // Increase by 30% and try again
+ res_len = (float)res_len + ((float)res_len * .3);
+ res = realloc(res, res_len);
+ break;
+ default:
+ goto out;
+ }
+ }
+ }
+out:
free(url_format);
- return amt ? res : content;
+ return res && rc ? res : content;
}
char* greentextify(char* content)
@@ -510,9 +533,9 @@ char* greentextify(char* content)
ind = re_results[2] + strlen(gt_string);
free(reg_string);
free(gt_string);
- pcre2_match_data_free(re_data);
}
+ pcre2_match_data_free(re_data);
pcre2_code_free(re);
return res;
}