| 185 | |
| 186 | |
| 187 | wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) |
| 188 | { |
| 189 | wxString converted; |
| 190 | std::vector<bool> braceStack; // true == formatting construct |
| 191 | |
| 192 | converted.reserve( aSource.length() ); |
| 193 | |
| 194 | for( wxUniChar c: aSource ) |
| 195 | { |
| 196 | if( aContext == CTX_NETNAME ) |
| 197 | { |
| 198 | if( c == '/' ) |
| 199 | converted += wxT( "{slash}" ); |
| 200 | else if( c == '\n' || c == '\r' ) |
| 201 | converted += wxEmptyString; // drop |
| 202 | else |
| 203 | converted += c; |
| 204 | } |
| 205 | else if( aContext == CTX_LIBID || aContext == CTX_LEGACY_LIBID ) |
| 206 | { |
| 207 | // We no longer escape '/' in LIB_IDs, but we used to |
| 208 | if( c == '/' && aContext == CTX_LEGACY_LIBID ) |
| 209 | converted += wxT( "{slash}" ); |
| 210 | else if( c == '\\' ) |
| 211 | converted += wxT( "{backslash}" ); |
| 212 | else if( c == '<' ) |
| 213 | converted += wxT( "{lt}" ); |
| 214 | else if( c == '>' ) |
| 215 | converted += wxT( "{gt}" ); |
| 216 | else if( c == ':' ) |
| 217 | converted += wxT( "{colon}" ); |
| 218 | else if( c == '\"' ) |
| 219 | converted += wxT( "{dblquote}" ); |
| 220 | else if( c == '\n' || c == '\r' ) |
| 221 | converted += wxEmptyString; // drop |
| 222 | else |
| 223 | converted += c; |
| 224 | } |
| 225 | else if( aContext == CTX_IPC ) |
| 226 | { |
| 227 | if( c == '/' ) |
| 228 | converted += wxT( "{slash}" ); |
| 229 | else if( c == ',' ) |
| 230 | converted += wxT( "{comma}" ); |
| 231 | else if( c == '\"' ) |
| 232 | converted += wxT( "{dblquote}" ); |
| 233 | else |
| 234 | converted += c; |
| 235 | } |
| 236 | else if( aContext == CTX_QUOTED_STR ) |
| 237 | { |
| 238 | if( c == '\"' ) |
| 239 | converted += wxT( "{dblquote}" ); |
| 240 | else |
| 241 | converted += c; |
| 242 | } |
| 243 | else if( aContext == CTX_JS_STR ) |
| 244 | { |