diff options
| author | liuxueli <[email protected]> | 2020-11-18 21:46:40 +0600 |
|---|---|---|
| committer | liuxueli <[email protected]> | 2020-11-18 21:46:40 +0600 |
| commit | 72ac4f1a1193b45564d6065bec3dfbb5bc9abe81 (patch) | |
| tree | 9de236d88d1b4fcde1ca92d893e0a4b27382d676 /src | |
| parent | 6b5f3c75441f20b3f24708fc92350ac87c00223f (diff) | |
转义/\-,;%$*特殊字符v2.9.10
Diffstat (limited to 'src')
| -rw-r--r-- | src/fs2prometheus.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/fs2prometheus.cpp b/src/fs2prometheus.cpp index 4a4f2d9..4782e23 100644 --- a/src/fs2prometheus.cpp +++ b/src/fs2prometheus.cpp @@ -27,26 +27,33 @@ struct FS_library_runtime g_FS2_LIBRARY_handle={ static char* str_unescape(char* s, char *d, int d_len) { - int i=0; + int i=0,j=0; int len=strlen(s); - for(i=0; i<len && i<d_len; i++) + for(i=0; i<len && j<d_len; i++) { - if(s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}') + if(s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}' || + s[i]=='/' || s[i]=='\\' || s[i]=='%' || s[i]=='*' || + s[i]=='$' || s[i]=='-' || s[i]==',' || s[i]==';') { - d[i]='_'; + if(i==0) + { + continue; + } + + d[j++]='_'; } else { - d[i]=s[i]; + d[j++]=s[i]; } } - if(d[i-1]=='_') + if(d[j-1]=='_') { - i-=1; + j-=1; } - d[i]='\0'; + d[j]='\0'; return 0; } |
