Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
23c4090f
Commit
23c4090f
authored
9 years ago
by
Steve Holme
Browse files
Options
Downloads
Patches
Plain Diff
imap: Quote other 'atom-specials' and not just the space character
Closes #517
parent
50bff12a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/imap.c
+18
-8
18 additions, 8 deletions
lib/imap.c
with
18 additions
and
8 deletions
lib/imap.c
+
18
−
8
View file @
23c4090f
...
...
@@ -1817,36 +1817,46 @@ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...)
*/
static
char
*
imap_atom
(
const
char
*
str
,
bool
escape_only
)
{
const
char
atom_specials
[]
=
"(){ %*]"
;
const
char
*
p1
;
char
*
p2
;
size_t
backsp_count
=
0
;
size_t
quote_count
=
0
;
bool
space
_exists
=
FALSE
;
bool
others
_exists
=
FALSE
;
size_t
newlen
=
0
;
char
*
newstr
=
NULL
;
if
(
!
str
)
return
NULL
;
/* Count any unescaped characters */
/* Look for "atom-specials", counting the backslash and quote characters as
these will need escapping */
p1
=
str
;
while
(
*
p1
)
{
if
(
*
p1
==
'\\'
)
backsp_count
++
;
else
if
(
*
p1
==
'"'
)
quote_count
++
;
else
if
(
!
escape_only
&&
(
*
p1
==
' '
))
space_exists
=
TRUE
;
else
if
(
!
escape_only
)
{
const
char
*
p3
=
atom_specials
;
while
(
*
p3
&&
!
others_exists
)
{
if
(
*
p1
==
*
p3
)
others_exists
=
TRUE
;
p3
++
;
}
}
p1
++
;
}
/* Does the input contain any
unescaped
characters? */
if
(
!
backsp_count
&&
!
quote_count
&&
!
space
_exists
)
/* Does the input contain any
"atom-special"
characters? */
if
(
!
backsp_count
&&
!
quote_count
&&
!
others
_exists
)
return
strdup
(
str
);
/* Calculate the new string length */
newlen
=
strlen
(
str
)
+
backsp_count
+
quote_count
+
(
space
_exists
?
2
:
0
);
newlen
=
strlen
(
str
)
+
backsp_count
+
quote_count
+
(
others
_exists
?
2
:
0
);
/* Allocate the new string */
newstr
=
(
char
*
)
malloc
((
newlen
+
1
)
*
sizeof
(
char
));
...
...
@@ -1855,7 +1865,7 @@ static char *imap_atom(const char *str, bool escape_only)
/* Surround the string in quotes if necessary */
p2
=
newstr
;
if
(
space
_exists
)
{
if
(
others
_exists
)
{
newstr
[
0
]
=
'"'
;
newstr
[
newlen
-
1
]
=
'"'
;
p2
++
;
...
...
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