Skip to content

Prevent duplicate configuration file includes - #39

Merged
TDannhauer merged 1 commit into
horde:FRAMEWORK_6_0from
horde6:fix_loadconfig
Feb 14, 2026
Merged

TDannhauer merged 1 commit into
horde:FRAMEWORK_6_0from
horde6:fix_loadconfig

Conversation

@amulet1

@amulet1 amulet1 commented Jan 5, 2026 •

Copy link
Copy Markdown
Member

Also: simplify the code.

This is a proper fix for #20.

Note, with this PR merged we no longer need guards like horde/kronolith#17 or horde/imp@b05084b.

@amulet1

amulet1 commented Jan 5, 2026

Copy link
Copy Markdown
Member Author

@TDannhauer Please merge.

@amulet1

amulet1 commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

@TDannhauer Not sure if you missed this PR.

@amulet1

amulet1 commented Jan 14, 2026 •

Copy link
Copy Markdown
Member Author

Just in case, here's a (AI generated) summary of the key changes between these two versions:

Security and Reliability Improvements

1. Path Traversal Protection

The new version adds realpath() normalization and duplicate checking to prevent malicious configuration files from being loaded multiple times or via path traversal attacks. The $checked array tracks already-processed files using their canonical paths.

2. File Existence Validation

The original version only checked is_file() for the vendor directory path, but unconditionally added other paths to $flist. The new version removes the separate is_file() check for the vendor path and consistently validates all files in the main loop, creating more uniform handling.

3. Safer Array Access

Changed !empty($conf['vhosts']) to ($conf['vhosts'] ?? false) using the null coalescing operator, which is more defensive against undefined array keys.

Code Structure Refactoring

4. Loop Simplification

Replaced the complex for loop with counter tracking ($k and $end) with a cleaner while (($v = array_shift($flist))) approach. This makes the vhost configuration logic easier to follow.

5. Vhost Logic Improvement

The vhost file loading now uses a boolean flag ($vhosts) instead of counting iterations, making the intent clearer and the logic more maintainable.

6. Code Formatting

Added consistent blank lines between property declarations and improved readability throughout the constructor.


The most critical change is the security enhancement that prevents potential exploits through path manipulation and duplicate file inclusion.

@amulet1

amulet1 commented Feb 2, 2026

Copy link
Copy Markdown
Member Author

@TDannhauer Please merge.

@TDannhauer
TDannhauer merged commit fcddd60 into horde:FRAMEWORK_6_0 Feb 14, 2026
0 of 4 checks passed
@TDannhauer

Copy link
Copy Markdown
Contributor

Please
Provide PRs to get rid of the now unnecessary guards

ralflang added a commit that referenced this pull request Mar 7, 2026
Release version 3.0.0-beta3

feat(responsive): add modern PSR-4 assets and view components
feat(auth): add JWT session binding support to Core
feat(auth): register JWT and Authentication service factories
Update HashTable.php
fix: Deprecated strlen(null) in Redis Hashtable on PHP 8.1+
feat(auth): add HS256 JWT generation and verification
feat(auth): add JWT generation support to Core
fix(core): add void return type to Browser::match()
Merge pull request #53 from amulet1/fix_deprecations
fix: Adjust code to avoid passing null value to is_dir()
fix: Add missing declaration of  property
Merge pull request #52 from amulet1/patch-1
(fix) Remove superfluous ':' in Driver.php
Merge pull request #51 from amulet1/patch-1
fix: Remove superfluous ')'
Merge pull request #30 from horde/TDannhauer-patch-ActiveSyncDriver1
Fix truncation and bodypartprefs logging
Update Driver.php
Refactor ActiveSync Driver to use null coalescing
Merge pull request #43 from CommanderRoot/update_openstreetmap_tile_url
Merge pull request #48 from amulet1/improve_ci
ci: Use latest dev-versions of horde/url and horde/test for unit tests
Merge pull request #47 from amulet1/fix_nlsconfig_test
fix: Correct Data Provider signature for Nlsconfigtest
Merge pull request #46 from amulet1/fix_js_xhr_abort
fix: Do not report 'Error when communicating with server' and similar errors triggered by user (browser) actions
Merge pull request #45 from amulet1/activesync_fix
fix: Correct maximum photo size check in _searchGal()
fix: Add missing 'source' field (expected by Horde_Core_ActiveSync_Driver::resolveRecipient)
fix: Correct broken code to support photos in resolveRecipient()
fix: Correct maximum photo size check
Merge pull request #40 from amulet1/amulet1-ci-fixes2
Merge pull request #39 from amulet1/fix_loadconfig
Use preferred tile.openstreetmap.org URL
fix: Prevent duplicate configuration file includes
Merge pull request #42 from amulet1/fix_host_undefined
fix: Redesign Horde::url() to fix undefined array key errors
Merge pull request #41 from amulet1/fix_activesync_undefined
fix: Use null coalescing operator in Horde_Core_ActiveSync_Driver to avoid undefined array key errors
fix: Adjust phpunit.xml.dist to initialize autoloader using test/bootstrap.php
fix: Add psr/http-factory to composer.json
fix: Redesign ci.yml to work again  * Replace unsupported ubuntu-20-04 with ubuntu-22.04  * Drop support for PHP 7.4 and 8.0  * Add support for PHP 8.1, 8.2, 8.3, 8.4  * Remove unused ssh keys  * Allow horde/horde-installer-plugin  * Other improvements
Merge pull request #38 from amulet1/fix_help_href
fix: Generate correct URLs for  tags in Horde_Help
Merge pull request #37 from amulet1/fix-signurl
fix: Add '=' after '_h' for Horde_Url objects in signUrl()/signQueryString()
Merge pull request #36 from amulet1/fix_SID
fix: Use session name when setting SID parameter
Merge pull request #29 from amulet1/autoload-fixes
Merge pull request #35 from jcdelepine/FRAMEWORK_6_0
meta:  correct Last-Translator email address
Merge pull request #31 from amulet1/fix-double-declaration
Merge pull request #32 from amulet1/fix_18cabbb
fix: Unbreak monthdateyear field rendering
Merge pull request #28 from amulet1/fix_signing
fix: Set  if not supplied in getInitialPage()
Update Driver.php
fix: Add support for autoloading of *_Ui_VarRenderer_* classes
fix: Remove extraneous '=' in signUrl() and signQueryString()
fix: Rendering invalid form types requires getter for message.
@amulet1
amulet1 deleted the fix_loadconfig branch March 23, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants