Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7b9295ff
Commit
7b9295ff
authored
Oct 28, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/yajl/Handle: strip newlines from error messages
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/981
parent
5f61d440
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
NEWS
NEWS
+4
-0
Handle.cxx
src/lib/yajl/Handle.cxx
+21
-1
No files found.
NEWS
View file @
7b9295ff
...
...
@@ -2,6 +2,10 @@ ver 0.22.2 (not yet released)
* database
- simple: purge songs and virtual directories for unavailable plugins
on update
* input
- qobuz/tidal: fix protocol errors due to newlines in error messages
* playlist
- soundcloud: fix protocol errors due to newlines in error messages
* state_file: save on shutdown
ver 0.22.1 (2020/10/17)
...
...
src/lib/yajl/Handle.cxx
View file @
7b9295ff
...
...
@@ -30,6 +30,24 @@
#include "Handle.hxx"
#include "util/RuntimeError.hxx"
#include "util/ScopeExit.hxx"
#include "util/StringStrip.hxx"
#include <cstring>
/**
* Strip whitespace at the beginning and end and replace newline
* characters which are illegal in the MPD protocol.
*/
static
const
char
*
StripErrorMessage
(
char
*
s
)
noexcept
{
s
=
Strip
(
s
);
while
(
auto
newline
=
std
::
strchr
(
s
,
'\n'
))
*
newline
=
';'
;
return
s
;
}
namespace
Yajl
{
...
...
@@ -41,7 +59,9 @@ Handle::ThrowError()
AtScopeExit
(
this
,
str
)
{
yajl_free_error
(
handle
,
str
);
};
throw
FormatRuntimeError
(
"Failed to parse JSON: %s"
,
str
);
throw
FormatRuntimeError
(
"Failed to parse JSON: %s"
,
StripErrorMessage
((
char
*
)
str
));
}
}
// namespace Yajl
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment