QString Binding::valueAsScriptString(const Unit *unit) const { if (type == Type_String) return escapedString(unit->stringAt(stringIndex)); else return valueAsString(unit); }
void Evaluate::addString(QString &string) { QString escapedString(string); escapedString.replace("\"", "\\\""); m_buffer.append("\""); m_buffer.append(escapedString); m_buffer.append("\""); }
// "Note that MYSQL* must be a valid, open connection. This is needed because the escaping depends on the character set in use by the server." void MySQLConnection::escape(std::string& text) { if ( ! text.empty() && conn_open && connectionHandle != nullptr) { char* tbuf = new char[text.length()*2+1]; size_t size = s->real_escape_string(connectionHandle, tbuf, text.c_str(), text.length()); std::string escapedString(tbuf, size); delete [] tbuf; text = escapedString; } }
void unescapeURL(const std::string& escaped, std::string& url) { String escapedString(escaped.data(), escaped.length()); String urlString = WebCore::decodeURLEscapeSequences(escapedString); CString utf8 = urlString.utf8(); url.clear(); url.append(utf8.data(), utf8.length()); }
/* On linux file names are just raw bytes, so also strings that cannot be encoded in any way * are valid file names. This mean that we cannot just store a file name as-is in a String * but we have to escape it. * On Windows the GLib file name encoding is always UTF-8 so we can optimize this case. */ String filenameToString(const char* filename) { if (!filename) return String(); #if OS(WINDOWS) return String::fromUTF8(filename); #else GUniquePtr<gchar> escapedString(g_uri_escape_string(filename, "/:", false)); return escapedString.get(); #endif }
void FileExplorerTab::OnOpenWidthDefaultApp(wxCommandEvent& e) { wxUnusedVar(e); wxArrayString paths; m_genericDirCtrl->GetPaths(paths); // Apply our environment before executing the file EnvSetter es; for(size_t i = 0; i < paths.GetCount(); i++) { bool bOpenOK = false; wxFileName fullpath(paths.Item(i)); // switch directory to the current files' path DirSaver ds; ::wxSetWorkingDirectory(fullpath.GetPath()); wxMimeTypesManager* mgr = wxTheMimeTypesManager; wxFileType* type = mgr->GetFileTypeFromExtension(fullpath.GetExt()); if(type) { wxString cmd = type->GetOpenCommand(fullpath.GetFullPath()); delete type; if(cmd.IsEmpty() == false) { wxExecute(cmd); bOpenOK = true; } } #ifdef __WXGTK__ if(!bOpenOK) { // All hell break loose, try xdg-open wxString cmd; wxString escapedString(fullpath.GetFullPath()); escapedString.Replace(" ", "\\ "); cmd << "xdg-open " << escapedString; ::wxExecute(cmd); bOpenOK = true; } #endif // fallback code: suggest to the user to open the file with CL if(!bOpenOK && wxMessageBox(wxString::Format( _("Could not find default application for file '%s'\nWould you like CodeLite to open it?"), fullpath.GetFullName().c_str()), _("CodeLite"), wxICON_QUESTION | wxYES_NO) == wxYES) { DoOpenItem(fullpath.GetFullPath()); } } }