mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
JSON: Filter string filed with special char
This commit is contained in:
parent
dc8a63fb3c
commit
426938cc8a
1 changed files with 15 additions and 1 deletions
|
@ -1572,11 +1572,25 @@ SrsJsonArray* SrsJsonAny::to_array()
|
|||
return p;
|
||||
}
|
||||
|
||||
string escape(string v)
|
||||
{
|
||||
stringstream ss;
|
||||
|
||||
for (int i = 0; i < v.length(); i++) {
|
||||
if (v.at(i) == '"') {
|
||||
ss << '\\';
|
||||
}
|
||||
ss << v.at(i);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
string SrsJsonAny::dumps()
|
||||
{
|
||||
switch (marker) {
|
||||
case SRS_JSON_String: {
|
||||
return "\"" + to_str() + "\"";
|
||||
return "\"" + escape(to_str()) + "\"";
|
||||
}
|
||||
case SRS_JSON_Boolean: {
|
||||
return to_boolean()? "true" : "false";
|
||||
|
|
Loading…
Reference in a new issue