Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Main
Synchronet
Commits
c3d6df80
Commit
c3d6df80
authored
1 year ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Wrap the body of parse_command() in a try/catch to turn errors into warnings
As requested by Keyop in #synchrob0yyz
parent
23ea3aa2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/imapservice.js
+109
-105
109 additions, 105 deletions
exec/imapservice.js
with
109 additions
and
105 deletions
exec/imapservice.js
+
109
−
105
View file @
c3d6df80
...
...
@@ -647,130 +647,134 @@ function handle_command(command, args, defs)
function
parse_command
(
line
)
{
function
execute_line
(
args
)
{
if
(
args
.
length
>=
2
)
{
command
=
args
[
1
].
toUpperCase
();
args
.
splice
(
1
,
1
);
if
(
handle_command
(
command
,
args
,
any_state_command_handlers
))
return
;
switch
(
state
)
{
case
UnAuthenticated
:
if
(
handle_command
(
command
,
args
,
unauthenticated_command_handlers
))
return
;
break
;
case
Authenticated
:
if
(
handle_command
(
command
,
args
,
authenticated_command_handlers
))
return
;
break
;
case
Selected
:
if
(
handle_command
(
command
,
args
,
selected_command_handlers
))
return
;
if
(
handle_command
(
command
,
args
,
authenticated_command_handlers
))
return
;
break
;
try
{
function
execute_line
(
args
)
{
if
(
args
.
length
>=
2
)
{
command
=
args
[
1
].
toUpperCase
();
args
.
splice
(
1
,
1
);
if
(
handle_command
(
command
,
args
,
any_state_command_handlers
))
return
;
switch
(
state
)
{
case
UnAuthenticated
:
if
(
handle_command
(
command
,
args
,
unauthenticated_command_handlers
))
return
;
break
;
case
Authenticated
:
if
(
handle_command
(
command
,
args
,
authenticated_command_handlers
))
return
;
break
;
case
Selected
:
if
(
handle_command
(
command
,
args
,
selected_command_handlers
))
return
;
if
(
handle_command
(
command
,
args
,
authenticated_command_handlers
))
return
;
break
;
}
}
// Ignore empty lines (Seamonkey sends these...)
if
(
args
.
length
>
0
)
tagged
(
args
[
0
],
"
BAD
"
,
"
Bad dog, no cookie.
"
);
}
// Ignore empty lines (Seamonkey sends these...)
if
(
args
.
length
>
0
)
tagged
(
args
[
0
],
"
BAD
"
,
"
Bad dog, no cookie.
"
);
}
function
parse_line
()
{
var
at_start
=
true
;
var
in_quote
=
false
;
var
paren_depth
=
0
;
var
string_len
;
var
args
=
[];
var
pos
;
function
parse_atom
()
{
var
ret
=
''
;
while
(
line
.
length
)
{
switch
(
line
.
charAt
(
0
))
{
case
'
)
'
:
return
(
ret
);
case
'
'
:
line
=
line
.
substr
(
1
);
return
(
ret
);
default
:
ret
+=
line
.
charAt
(
0
);
line
=
line
.
substr
(
1
);
break
;
function
parse_line
()
{
var
at_start
=
true
;
var
in_quote
=
false
;
var
paren_depth
=
0
;
var
string_len
;
var
args
=
[];
var
pos
;
function
parse_atom
()
{
var
ret
=
''
;
while
(
line
.
length
)
{
switch
(
line
.
charAt
(
0
))
{
case
'
)
'
:
return
(
ret
);
case
'
'
:
line
=
line
.
substr
(
1
);
return
(
ret
);
default
:
ret
+=
line
.
charAt
(
0
);
line
=
line
.
substr
(
1
);
break
;
}
}
return
(
ret
);
}
return
(
ret
);
}
function
parse_string
()
{
var
ret
=
''
;
if
(
line
.
search
(
/^{
([
0-9
]
+
)
}$/
)
!==
0
)
throw
new
Error
(
'
invalid string literal (
'
+
line
+
'
), aborting
'
);
line
=
line
.
replace
(
/^{
([
0-9
]
+
)
}$/
,
"
$1
"
);
client
.
socket
.
send
(
"
+ Give me more of that good stuff
\r\n
"
);
var
len
=
parseInt
(
line
);
if
(
len
)
{
ret
=
client
.
socket
.
recv
(
len
);
if
(
ret
===
null
)
throw
new
Error
(
'
recv() of
'
+
len
+
'
bytes returned null
'
);
if
(
ret
.
length
!==
len
)
throw
new
Error
(
'
recv() of
'
+
len
+
'
bytes returned a string with
'
+
ret
.
length
+
'
instead.
'
);
line
=
client
.
socket
.
recvline
(
10240
,
1800
);
function
parse_string
()
{
var
ret
=
''
;
if
(
line
.
search
(
/^{
([
0-9
]
+
)
}$/
)
!==
0
)
throw
new
Error
(
'
invalid string literal (
'
+
line
+
'
), aborting
'
);
line
=
line
.
replace
(
/^{
([
0-9
]
+
)
}$/
,
"
$1
"
);
client
.
socket
.
send
(
"
+ Give me more of that good stuff
\r\n
"
);
var
len
=
parseInt
(
line
);
if
(
len
)
{
ret
=
client
.
socket
.
recv
(
len
);
if
(
ret
===
null
)
throw
new
Error
(
'
recv() of
'
+
len
+
'
bytes returned null
'
);
if
(
ret
.
length
!==
len
)
throw
new
Error
(
'
recv() of
'
+
len
+
'
bytes returned a string with
'
+
ret
.
length
+
'
instead.
'
);
line
=
client
.
socket
.
recvline
(
10240
,
1800
);
}
else
{
line
=
undefined
;
}
return
(
ret
);
}
else
{
line
=
undefined
;
function
parse_quotedstring
()
{
var
ret
=
''
;
line
=
line
.
substr
(
1
);
// Remove leading "
while
(
line
.
length
)
{
switch
(
line
.
charAt
(
0
))
{
case
'
"
'
:
line
=
line
.
substr
(
1
);
return
(
ret
);
default
:
ret
+=
line
.
charAt
(
0
);
line
=
line
.
substr
(
1
);
break
;
}
}
return
(
ret
);
}
return
(
ret
);
}
function
parse_quotedstring
()
{
var
ret
=
''
;
line
=
line
.
substr
(
1
);
// Remove leading "
while
(
line
.
length
)
{
while
(
line
)
{
switch
(
line
.
charAt
(
0
))
{
case
'
"
'
:
args
.
push
(
parse_quotedstring
());
break
;
case
'
)
'
:
line
=
line
.
substr
(
1
);
return
(
ret
);
default
:
ret
+=
line
.
charAt
(
0
);
return
(
args
);
case
'
(
'
:
line
=
line
.
substr
(
1
);
args
.
push
(
parse_line
());
break
;
case
'
{
'
:
args
.
push
(
parse_string
());
break
;
case
'
'
:
line
=
line
.
substr
(
1
);
break
;
default
:
args
.
push
(
parse_atom
());
break
;
}
}
return
(
ret
);
return
(
args
);
}
while
(
line
)
{
switch
(
line
.
charAt
(
0
))
{
case
'
"
'
:
args
.
push
(
parse_quotedstring
());
break
;
case
'
)
'
:
line
=
line
.
substr
(
1
);
return
(
args
);
case
'
(
'
:
line
=
line
.
substr
(
1
);
args
.
push
(
parse_line
());
break
;
case
'
{
'
:
args
.
push
(
parse_string
());
break
;
case
'
'
:
line
=
line
.
substr
(
1
);
break
;
default
:
args
.
push
(
parse_atom
());
break
;
}
}
return
(
args
);
send_updates
();
return
(
execute_line
(
parse_line
()));
}
catch
(
error
)
{
log
(
LOG_WARNING
,
"
Exception during command parsing:
"
+
error
);
}
send_updates
();
return
(
execute_line
(
parse_line
()));
}
// Command handling functions
...
...
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