Skip to content

do not create empty userid when attribute does not have allowed chars - #8634

Merged
rullzer merged 3 commits into
masterfrom
ldap-no-empty-names
Mar 5, 2018
Merged

do not create empty userid when attribute does not have allowed chars#8634
rullzer merged 3 commits into
masterfrom
ldap-no-empty-names

Conversation

@blizzz

Copy link
Copy Markdown
Member

If some funny attribute contains only characters that are not allowed for user ids, one empty userid would have been generated. Comes with unit test.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Comment threadapps/user_ldap/lib/Access.php Outdated
'level' => Util::WARN,
]);
// we don't attempt to set a username here. We can go for
// for an alternativ 4 digit random number as we would append

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternative ;)

$name = preg_replace('/[^a-zA-Z0-9_.@-]/u', '', $name);

if($name === '') {
throw new \InvalidArgumentException('provided name template for username does not contain any allowed characters');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing in PHPDoc

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mh, PhpStorm not complaining, usually it does… odd. Anyway you're right.

@MorrisJobkeMorrisJobke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside the little nitpicks: 👍

@MorrisJobke

Copy link
Copy Markdown
Member

unit tests fail iconv(): Detected an illegal character in input string 🤔

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@codecov

codecovBot commented Mar 5, 2018

Copy link
Copy Markdown

Codecov Report

Merging #8634 into master will decrease coverage by 20.49%.
The diff coverage is 0%.

@@ Coverage Diff @@## master #8634 +/- ##
============================================
- Coverage 51.87% 31.37% -20.5% - Complexity 25422 25424 +2 
============================================
Files 1609 1609 Lines 95343 95352 +9 Branches 1378 1378 ============================================
- Hits 49455 29914 -19541 - Misses 45888 65438 +19550
Impacted FilesCoverage ΔComplexity Δ
apps/user_ldap/lib/Access.php0% <0%> (-35.79%)323 <0> (+2)
...rivate/Authentication/Token/DefaultTokenMapper.php0% <0%> (-100%)11% <0%> (ø)
apps/user_ldap/lib/Migration/UUIDFix.php0% <0%> (-100%)5% <0%> (ø)
lib/public/Files/ForbiddenException.php0% <0%> (-100%)2% <0%> (ø)
apps/files_trashbin/lib/AppInfo/Application.php0% <0%> (-100%)2% <0%> (ø)
lib/private/DB/OCSqlitePlatform.php0% <0%> (-100%)5% <0%> (ø)
lib/private/Share20/Hooks.php0% <0%> (-100%)3% <0%> (ø)
lib/private/Files/Cache/Wrapper/JailPropagator.php0% <0%> (-100%)1% <0%> (ø)
...ivate/Files/Cache/Wrapper/CachePermissionsMask.php0% <0%> (-100%)3% <0%> (ø)
apps/user_ldap/lib/BackendUtility.php0% <0%> (-100%)1% <0%> (ø)
... and 374 more

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz

Copy link
Copy Markdown
MemberAuthor

unit tests fail iconv(): Detected an illegal character in input string thinking

iconv :-/

»Caution

If and how //TRANSLIT works exactly depends on the system's iconv() implementation (cf. ICONV_IMPL). Some implementations are known to ignore //TRANSLIT, so the conversion is likely to fail for characters which are illegal for the out_charset.«
php doc

Yet there are no runtime or any config options available for PHP. So I changed the behaviour slightly: try to transliterate, be silent about issues, otherwise non-ascii characters are removed anyhow.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbugfeature: ldap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@blizzz@MorrisJobke@rullzer