Fixed an issue where PSQL tool is not opening if database name have HTML characters in the name. #8365

pull/8348/merge
Aditya Toshniwal 2025-01-17 14:53:24 +05:30 committed by GitHub
parent 99e1f005fc
commit 1216f075ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 7 deletions

View File

@ -108,7 +108,7 @@ def panel(trans_id):
'db': underscore_escape(data['db_name']),
'server_type': params['server_type'],
'is_enable': config.ENABLE_PSQL,
'title': underscore_unescape(params['title']),
'title': underscore_escape(params['title']),
'theme': params['theme'],
'o_db_name': underscore_escape(data['db_name']),
'role': underscore_escape(data['role']),

View File

@ -143,14 +143,13 @@ export default class Psql {
const [panelUrl, db_label] = this.getPanelUrls(transId, parentData);
const escapedTitle = _.escape(panelTitle);
const open_new_tab = usePreferences.getState().getPreferencesForModule('browser').new_browser_tab_open;
pgAdmin.Browser.Events.trigger(
'pgadmin:tool:show',
`${BROWSER_PANELS.PSQL_TOOL}_${transId}`,
panelUrl,
{title: escapedTitle, db: db_label},
{title: panelTitle, db: db_label},
{title: panelTitle, icon: 'pg-font-icon icon-terminal', manualClose: false, renamable: true},
Boolean(open_new_tab?.includes('psql_tool'))
);
@ -190,7 +189,7 @@ export default class Psql {
<PgAdminProvider value={pgAdmin}>
<ModalProvider>
<NotifierProvider pgAdmin={pgAdmin} pgWindow={pgWindow} />
<PsqlComponent params={params} pgAdmin={pgAdmin} />
<PsqlComponent params={JSON.parse(params)} pgAdmin={pgAdmin} />
</ModalProvider>
</PgAdminProvider>
</Theme>

View File

@ -332,12 +332,14 @@ def panel(trans_id):
params['layout'] = get_setting('SQLEditor/Layout')
params['macros'] = get_user_macros()
params['is_desktop_mode'] = current_app.PGADMIN_RUNTIME
params['title'] = underscore_escape(params['title'])
params['selectedNodeInfo'] = underscore_escape(params['selectedNodeInfo'])
if 'database_name' in params:
params['database_name'] = underscore_escape(params['database_name'])
return render_template(
"sqleditor/index.html",
title=underscore_unescape(params['title']),
title=underscore_escape(params['title']),
params=json.dumps(params),
)

View File

@ -221,7 +221,7 @@ export default class SQLEditor {
'pgadmin:tool:show',
`${BROWSER_PANELS.QUERY_TOOL}_${trans_id}`,
panel_url,
{...params, title: _.escape(panel_title.replace('\\', '\\\\')), selectedNodeInfo: JSON.stringify(selectedNodeInfo)},
{...params, title: panel_title, selectedNodeInfo: JSON.stringify(selectedNodeInfo)},
{title: panel_title, icon: icon, tooltip: tooltip, renamable: true},
Boolean(open_new_tab?.includes('qt'))
);
@ -229,7 +229,7 @@ export default class SQLEditor {
}
async loadComponent(container, params) {
const selectedNodeInfo = params.selectedNodeInfo ? JSON.parse(params.selectedNodeInfo) : params.selectedNodeInfo;
const selectedNodeInfo = params.selectedNodeInfo ? JSON.parse(_.unescape(params.selectedNodeInfo)) : params.selectedNodeInfo;
pgAdmin.Browser.keyboardNavigation.init();
await listenPreferenceBroadcast();
const root = ReactDOM.createRoot(container);

View File

@ -448,6 +448,13 @@ export default function QueryToolDataGrid({columns, rows, totalRowCount, dataCha
rowIdx
}, true);
}
// This is needed to prevent Codemirror from triggering copy.
if(mode == 'SELECT' && (e.ctrlKey || e.metaKey) && e.key !== 'Control' && e.keyCode == 67) {
// taken care by handleCopy.
e.preventDefault();
e.stopPropagation();
}
}}
{...props}
/>