Skip to content

Commit 647a7f8

Browse files
authored
reload fixes (#457)
* security fixes and theme preview * securit fix replace * Update CHANGELOG.md * 5.3.3 * namespace guide entfernt * fixed reload * Bump version to 5.3.4 and fix various issues Updated version to 5.3.4 and fixed multiple issues including JSON parsing errors, framework template loading, and security vulnerabilities. * 5.3.6 * alle laden inline via session erlauben * Fix iOS Safari touch events (thx @alexwenz) and update changelog * Address review comments: add missing translations and secure host usage
1 parent 6b3d224 commit 647a7f8

File tree

12 files changed

+101
-17
lines changed

12 files changed

+101
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# REDAXO consent_manager - Changelog
22

3+
## Version 5.4.0 - 11.02.2026
4+
5+
- **Feature:** Inline-Consent kann nun optional auf "Session-Scope" beschränkt werden. Zustimmungen gelten dann nur, solange der Browser-Tab offen ist (via `sessionStorage`). Konfigurierbar unter Einstellungen.
6+
- **Fix:** Reload-Loop behoben: Das Öffnen der Details aus einem Inline-Element führte unter Umständen zu einem sofortigen Neuladen der Seite.
7+
- **Fix:** iOS Safari Touch-Event Handling verbessert: Button musste unter Umständen doppelt getippt werden; nun reagiert er sofort (Danke @alexwenz).
8+
- **System:** Build-Skript aktualisiert für bessere Minifizierung.
9+
10+
11+
312
## Version 5.3.4 - 29.01.2026
413

514
- **Fix:** JSON Parsing Fehler im Frontend behoben (`double-escaping` von HTML-Attributen entfernt), was zu Fehlern beim Laden der Cookie-Gruppen führte (`safeJSONParse failed`).

assets/consent_inline.js

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ if (typeof window.consentManagerInline !== 'undefined') {
4747
});
4848
});
4949

50-
// Cookie-Änderungen überwachen
51-
var lastCookieValue = self.getCookie('consentmanager');
50+
// Cookie/Storage-Änderungen überwachen
51+
var lastStorageValue = self.getStorageValue();
5252
setInterval(function() {
53-
var currentCookieValue = self.getCookie('consentmanager');
54-
if (currentCookieValue !== lastCookieValue) {
55-
lastCookieValue = currentCookieValue;
53+
var currentStorageValue = self.getStorageValue();
54+
if (currentStorageValue !== lastStorageValue) {
55+
lastStorageValue = currentStorageValue;
5656
self.updateAllPlaceholders();
5757
}
5858
}, 1000);
@@ -83,8 +83,8 @@ if (typeof window.consentManagerInline !== 'undefined') {
8383
});
8484
}
8585

86-
// Event-Handler für Buttons mit spezifischer Priorität
87-
document.addEventListener('click', function(e) {
86+
// Helper function for button click handling (unified for click and touchstart)
87+
var handleButtonClick = function(e) {
8888
// Eindeutig nur "Einmal laden" Button - Lädt NUR diesen einen Container
8989
if (e.target.matches('.consent-inline-once') && !e.target.matches('.consent-inline-allow-all')) {
9090
e.preventDefault();
@@ -115,7 +115,18 @@ if (typeof window.consentManagerInline !== 'undefined') {
115115
self.showDetails(serviceKey);
116116
return;
117117
}
118-
});
118+
};
119+
120+
// Event-Handler für Buttons mit spezifischer Priorität
121+
document.addEventListener('click', handleButtonClick);
122+
123+
// iOS Safari Fix: touchend statt touchstart verwenden
124+
// touchend verhindert Hover-State und triggert sofort
125+
document.addEventListener('touchend', function(e) {
126+
if (e.target.matches('.consent-inline-once, .consent-inline-allow-all, .consent-inline-details')) {
127+
handleButtonClick(e);
128+
}
129+
}, { passive: false });
119130

120131
// Fallback: Regelmäßige Prüfung
121132
setInterval(function() {
@@ -382,7 +393,7 @@ if (typeof window.consentManagerInline !== 'undefined') {
382393
} catch (e) {
383394
// ignore and fallback to default
384395
}
385-
var cookieValue = this.getCookie('consentmanager');
396+
var cookieValue = this.getStorageValue();
386397

387398
if (!cookieValue) {
388399
return {
@@ -508,6 +519,13 @@ if (typeof window.consentManagerInline !== 'undefined') {
508519
},
509520

510521
setCookieData: function(data) {
522+
if (this.isSessionScope()) {
523+
try {
524+
sessionStorage.setItem('consentmanager', JSON.stringify(data));
525+
} catch(e) { /* ignore */ }
526+
return;
527+
}
528+
511529
// Vor dem Setzen: alte / invalide Cookies entfernen
512530
var shouldClear = false;
513531
try {
@@ -544,6 +562,26 @@ if (typeof window.consentManagerInline !== 'undefined') {
544562
'; path=/; SameSite=Lax';
545563
},
546564

565+
isSessionScope: function() {
566+
try {
567+
return (typeof window.consentManagerInlineOptions !== 'undefined' &&
568+
window.consentManagerInlineOptions.sessionScope === true);
569+
} catch(e) {
570+
return false;
571+
}
572+
},
573+
574+
getStorageValue: function() {
575+
if (this.isSessionScope()) {
576+
try {
577+
return sessionStorage.getItem('consentmanager');
578+
} catch(e) {
579+
return null;
580+
}
581+
}
582+
return this.getCookie('consentmanager');
583+
},
584+
547585
getCookie: function(name) {
548586
var value = '; ' + document.cookie;
549587
var parts = value.split('; ' + name + '=');

assets/consent_manager_frontend.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ function safeJSONParse(input, fallback) {
291291
if (actions.indexOf('reload') !== -1) {
292292
// Warte auf Box-Close und reload dann
293293
var checkClose = setInterval(function() {
294-
if (!document.querySelector('.consent_manager-box')) {
294+
var box = document.getElementById('consent_manager-background');
295+
if (!box || box.classList.contains('consent_manager-hidden')) {
295296
clearInterval(checkClose);
296297
location.reload();
297298
}

assets/consent_manager_frontend.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inline.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ if (class_exists(InlineConsent::class)) {
225225

226226
---
227227

228+
## 🔧 Backend-Konfiguration: Globale Einstellungen
229+
230+
### Session-Scope (Nur für die Sitzung merken)
231+
232+
Unter **Consent Manager → Einstellungen** kann die Option **"Inline-Consent: Zustimmung nur für Session merken"** aktiviert werden.
233+
234+
- **Deaktiviert (Standard):** Zustimmungen für Inline-Elemente (z.B. "Einmal laden" oder "Alle zulassen") werden als persistentes Cookie gespeichert (Standard 1 Jahr).
235+
- **Aktiviert:** Zustimmungen werden im `sessionStorage` des Browsers gespeichert. Sobald der Tab oder Browser geschlossen wird, verfällt die Zustimmung automatisch.
236+
237+
Diese Einstellung ist besonders datenschutzfreundlich, da Besucher bei jedem neuen Besuch erneut explizit zustimmen müssen.
238+
228239
## 🔧 Backend-Konfiguration: Platzhalter pro Service
229240

230241
Im Backend unter **Consent Manager → Cookies** können für jeden Service individuelle Platzhalter-Einstellungen vorgenommen werden:

lang/de_de.lang

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ consent_manager_import_standard_update_success = Standard Setup Update erfolgrei
308308
consent_manager_import_standard_update_error = Standard Setup Update fehlgeschlagen: {0}
309309

310310
# Inline Consent Einstellungen
311+
consent_manager_config_inline_consent_session_scope = Inline-Consent für Session merken
312+
consent_manager_config_inline_consent_session_scope_enable = Ja, Auswahl für die Session speichern
313+
consent_manager_config_inline_consent_session_scope_desc = Wenn aktiviert, wird die Auswahl "Einmal laden" und "Alle erlauben" (im Inline-Kontext) für die Dauer der Browsersitzung gespeichert (sessionStorage). Standardmäßig gilt "Einmal laden" nur bis zum Neuladen der Seite und "Alle erlauben" speichert dauerhaft im Cookie. Mit dieser Option verhält sich "Alle erlauben" wie eine Session-Freigabe.
314+
311315
consent_manager_config_inline_only_mode = Nur Inline-Consent verwenden
312316
consent_manager_config_inline_only_mode_desc = Das globale Consent-Popup wird standardmäßig nicht angezeigt. Consent wird nur bei Bedarf über doConsent() abgefragt.
313317

lang/en_gb.lang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ consent_manager_import_standard_update_error = Standard setup update failed: {0}
416416
consent_manager_quickstart_status_final = Completion
417417

418418
# Inline Consent Settings
419+
# Inline Consent Settings
420+
consent_manager_config_inline_consent_session_scope = Remember inline consent for session
421+
consent_manager_config_inline_consent_session_scope_enable = Yes, save selection for the session
422+
consent_manager_config_inline_consent_session_scope_desc = If enabled, the selection "Load once" and "Allow all" (in inline context) is stored for the duration of the browser session (sessionStorage). By default, "Load once" applies only until the page is reloaded and "Allow all" saves permanently in the cookie. With this option, "Allow all" behaves like a session approval.
423+
419424
consent_manager_config_inline_only_mode = Use inline consent only
420425
consent_manager_config_inline_only_mode_desc = The global consent popup is not displayed by default. Consent is only requested when needed via doConsent().
421426

lang/sv_se.lang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,11 @@ consent_manager_import_standard_update_error = Standard setup-uppdatering missly
396396
consent_manager_quickstart_status_final = Slutförande
397397

398398
# Inline Consent-inställningar
399+
# Inline Consent Settings
400+
consent_manager_config_inline_consent_session_scope = Kom ihåg inline-samtycke för sessionen
401+
consent_manager_config_inline_consent_session_scope_enable = Ja, spara valet för sessionen
402+
consent_manager_config_inline_consent_session_scope_desc = Om aktiverat sparas valet "Ladda en gång" och "Tillåt alla" (i inline-sammanhang) under webbläsarsessionens varaktighet (sessionStorage). Som standard gäller "Ladda en gång" endast tills sidan laddas om och "Tillåt alla" sparas permanent i cookien. Med detta alternativ beter sig "Tillåt alla" som ett sessionsgodkännande.
403+
399404
consent_manager_config_inline_only_mode = Använd endast inline-consent
400405
consent_manager_config_inline_only_mode_desc = Den globala consent-popupen visas inte som standard. Samtycke begärs endast vid behov via doConsent().
401406

lib/Frontend.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ public static function getFrontendCss(): string
345345
// 1. Prüfen ob Domain-spezifisches Theme existiert
346346
$domainTheme = null;
347347
$hasDomainConfig = false;
348-
if (is_string(rex_request::server('HTTP_HOST'))) {
348+
if ('' !== Utility::hostname()) {
349349
$frontend = new self(0);
350-
$frontend->setDomain(rex_request::server('HTTP_HOST'));
350+
$frontend->setDomain(Utility::hostname());
351351

352352
// Prüfen ob Domain konfiguriert ist
353353
if ('' !== $frontend->domainName) {
@@ -544,8 +544,8 @@ public static function getCookieList(string $format = 'table', ?string $domainNa
544544

545545
if (null === $domainName) {
546546
// Aktuelle Domain verwenden
547-
if (is_string(rex_request::server('HTTP_HOST'))) {
548-
$consent->setDomain(rex_request::server('HTTP_HOST'));
547+
if ('' !== Utility::hostname()) {
548+
$consent->setDomain(Utility::hostname());
549549
}
550550
} else {
551551
// Spezifische Domain verwenden

lib/InlineConsent.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,14 @@ public static function getJavaScript(): string
397397
}
398398
self::$jsOutputted = true;
399399

400+
$addon = \rex_addon::get('consent_manager');
401+
$sessionScope = $addon->getConfig('inline_consent_session_scope') ? 'true' : 'false';
402+
403+
$configScript = '<script>window.consentManagerInlineOptions = { sessionScope: ' . $sessionScope . ' };</script>';
404+
400405
// JavaScript-Datei laden
401406
$jsPath = rex_url::addonAssets('consent_manager', 'consent_inline.js');
402-
return '<script defer src="' . $jsPath . '"></script>';
407+
return $configScript . '<script defer src="' . $jsPath . '"></script>';
403408
}
404409

405410
/**

0 commit comments

Comments
 (0)