Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nextcloud mail - PostGuard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Kolijn
Nextcloud mail - PostGuard
Commits
ea362877
Commit
ea362877
authored
4 years ago
by
Cyrille Bollu
Browse files
Options
Downloads
Patches
Plain Diff
Avoids using iconv with '//IGNORE' flag if possible
Signed-off-by:
Cyrille Bollu
<
cyr.debian@bollu.be
>
parent
ba40c6e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Address.php
+6
-0
6 additions, 0 deletions
lib/Address.php
lib/Model/IMAPMessage.php
+8
-1
8 additions, 1 deletion
lib/Model/IMAPMessage.php
with
14 additions
and
1 deletion
lib/Address.php
+
6
−
0
View file @
ea362877
...
@@ -79,6 +79,12 @@ class Address implements JsonSerializable {
...
@@ -79,6 +79,12 @@ class Address implements JsonSerializable {
return
null
;
return
null
;
}
}
// Lets make sure the e-mail is valid UTF-8 at all times
// Lets make sure the e-mail is valid UTF-8 at all times
// Try a soft conversion first (some installations, eg: Alpine linux,
// have issues with the '//IGNORE' option)
$utf8
=
iconv
(
'UTF-8'
,
'UTF-8'
,
$email
);
if
(
$utf8
!==
false
)
{
return
$utf8
;
}
$utf8
=
iconv
(
"UTF-8"
,
"UTF-8//IGNORE"
,
$email
);
$utf8
=
iconv
(
"UTF-8"
,
"UTF-8//IGNORE"
,
$email
);
if
(
$utf8
===
false
)
{
if
(
$utf8
===
false
)
{
throw
new
\Exception
(
"Email address <
$email
> could not be converted via iconv"
);
throw
new
\Exception
(
"Email address <
$email
> could not be converted via iconv"
);
...
...
This diff is collapsed.
Click to expand it.
lib/Model/IMAPMessage.php
+
8
−
1
View file @
ea362877
...
@@ -273,7 +273,14 @@ class IMAPMessage implements IMessage, JsonSerializable {
...
@@ -273,7 +273,14 @@ class IMAPMessage implements IMessage, JsonSerializable {
* @return string
* @return string
*/
*/
public
function
getSubject
():
string
{
public
function
getSubject
():
string
{
return
iconv
(
"UTF-8"
,
"UTF-8//IGNORE"
,
$this
->
getEnvelope
()
->
subject
);
// Try a soft conversion first (some installations, eg: Alpine linux,
// have issues with the '//IGNORE' option)
$subject
=
$this
->
getEnvelope
()
->
subject
;
$utf8
=
iconv
(
'UTF-8'
,
'UTF-8'
,
$subject
);
if
(
$utf8
!==
false
)
{
return
$utf8
;
}
return
iconv
(
"UTF-8"
,
"UTF-8//IGNORE"
,
$subject
);
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment