diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-09 19:01:15 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-09 19:01:15 +0300 |
commit | f63ed76597b462c60b3a6ad89f8c165ffb87d00c (patch) | |
tree | 2aca3537930bce28acff14c0cee0a11fa1988661 /src/gmcerts.c | |
parent | 5f9685010addd4a0f04c13f889856084381dd1c6 (diff) | |
parent | ee17ef3d0135027fbc4ff816dd9e793b4bb0b883 (diff) |
Merge branch 'dev' into work/typesetter
# Conflicts:
# src/gmdocument.c
# src/ui/documentwidget.c
# src/ui/inputwidget.h
Diffstat (limited to 'src/gmcerts.c')
-rw-r--r-- | src/gmcerts.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/gmcerts.c b/src/gmcerts.c index 35d784f6..8577cf2b 100644 --- a/src/gmcerts.c +++ b/src/gmcerts.c | |||
@@ -105,7 +105,7 @@ void deserialize_GmIdentity(iGmIdentity *d, iStream *ins) { | |||
105 | iString url; | 105 | iString url; |
106 | init_String(&url); | 106 | init_String(&url); |
107 | deserialize_String(&url, ins); | 107 | deserialize_String(&url, ins); |
108 | insert_StringSet(d->useUrls, &url); | 108 | setUse_GmIdentity(d, &url, iTrue); |
109 | deinit_String(&url); | 109 | deinit_String(&url); |
110 | } | 110 | } |
111 | } | 111 | } |
@@ -161,11 +161,30 @@ iBool isUsedOn_GmIdentity(const iGmIdentity *d, const iString *url) { | |||
161 | return iFalse; | 161 | return iFalse; |
162 | } | 162 | } |
163 | 163 | ||
164 | iBool isUsedOnDomain_GmIdentity(const iGmIdentity *d, const iRangecc domain) { | ||
165 | iConstForEach(StringSet, i, d->useUrls) { | ||
166 | const iRangecc host = urlHost_String(i.value); | ||
167 | if (equalRangeCase_Rangecc(host, domain)) { | ||
168 | return iTrue; | ||
169 | } | ||
170 | } | ||
171 | return iFalse; | ||
172 | } | ||
173 | |||
164 | void setUse_GmIdentity(iGmIdentity *d, const iString *url, iBool use) { | 174 | void setUse_GmIdentity(iGmIdentity *d, const iString *url, iBool use) { |
165 | if (use && isUsedOn_GmIdentity(d, url)) { | 175 | if (use && isUsedOn_GmIdentity(d, url)) { |
166 | return; /* Redudant. */ | 176 | return; /* Redudant. */ |
167 | } | 177 | } |
168 | if (use) { | 178 | if (use) { |
179 | /* Remove all use-URLs that become redundant by this newly added URL. */ | ||
180 | /* TODO: StringSet could have a non-const iterator. */ | ||
181 | iForEach(Array, i, &d->useUrls->strings.values) { | ||
182 | iString *used = i.value; | ||
183 | if (startsWithCase_String(used, cstr_String(url))) { | ||
184 | deinit_String(used); | ||
185 | remove_ArrayIterator(&i); | ||
186 | } | ||
187 | } | ||
169 | #if !defined (NDEBUG) | 188 | #if !defined (NDEBUG) |
170 | const iBool wasInserted = | 189 | const iBool wasInserted = |
171 | #endif | 190 | #endif |
@@ -182,7 +201,11 @@ void clearUse_GmIdentity(iGmIdentity *d) { | |||
182 | } | 201 | } |
183 | 202 | ||
184 | const iString *name_GmIdentity(const iGmIdentity *d) { | 203 | const iString *name_GmIdentity(const iGmIdentity *d) { |
185 | return collect_String(subject_TlsCertificate(d->cert)); | 204 | iString *name = collect_String(subject_TlsCertificate(d->cert)); |
205 | if (startsWith_String(name, "CN = ")) { | ||
206 | remove_Block(&name->chars, 0, 5); | ||
207 | } | ||
208 | return name; | ||
186 | } | 209 | } |
187 | 210 | ||
188 | iDefineTypeConstruction(GmIdentity) | 211 | iDefineTypeConstruction(GmIdentity) |