Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

エスケープの動作がおかしい #131

Open
abap34 opened this issue May 31, 2024 · 0 comments
Open

エスケープの動作がおかしい #131

abap34 opened this issue May 31, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@abap34
Copy link
Owner

abap34 commented May 31, 2024

dot 言語や jsonの出力に使うために以下のようなエスケープを行ってくれる関数を使っている。

almo/src/utils.hpp

Lines 179 to 192 in a512df9

// 文字列を受け取り、ダブルクオーテーションや改行などをエスケープする
// https://stackoverflow.com/questions/7724448/simple-json-string-escape-for-c
std::string escape(const std::string &s) {
std::ostringstream o;
for (auto c = s.cbegin(); c != s.cend(); c++) {
if (*c == '"' || *c == '\\' || ('\x00' <= *c && *c <= '\x1f')) {
o << "\\u"
<< std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(*c);
} else {
o << *c;
}
}
return o.str();
}

しかし、{, }, |, >, < がエスケープ対象から漏れているため、dot言語の出力が崩れる場合がある。修正が必要

@abap34 abap34 added the bug Something isn't working label May 31, 2024
@abap34 abap34 added the good first issue Good for newcomers label Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant