Fixed an issue where PSQL tool is not opening if database name have HTML characters in the name. #8365
parent
99e1f005fc
commit
1216f075ce
|
@ -108,7 +108,7 @@ def panel(trans_id):
|
||||||
'db': underscore_escape(data['db_name']),
|
'db': underscore_escape(data['db_name']),
|
||||||
'server_type': params['server_type'],
|
'server_type': params['server_type'],
|
||||||
'is_enable': config.ENABLE_PSQL,
|
'is_enable': config.ENABLE_PSQL,
|
||||||
'title': underscore_unescape(params['title']),
|
'title': underscore_escape(params['title']),
|
||||||
'theme': params['theme'],
|
'theme': params['theme'],
|
||||||
'o_db_name': underscore_escape(data['db_name']),
|
'o_db_name': underscore_escape(data['db_name']),
|
||||||
'role': underscore_escape(data['role']),
|
'role': underscore_escape(data['role']),
|
||||||
|
|
|
@ -143,14 +143,13 @@ export default class Psql {
|
||||||
|
|
||||||
const [panelUrl, db_label] = this.getPanelUrls(transId, parentData);
|
const [panelUrl, db_label] = this.getPanelUrls(transId, parentData);
|
||||||
|
|
||||||
const escapedTitle = _.escape(panelTitle);
|
|
||||||
const open_new_tab = usePreferences.getState().getPreferencesForModule('browser').new_browser_tab_open;
|
const open_new_tab = usePreferences.getState().getPreferencesForModule('browser').new_browser_tab_open;
|
||||||
|
|
||||||
pgAdmin.Browser.Events.trigger(
|
pgAdmin.Browser.Events.trigger(
|
||||||
'pgadmin:tool:show',
|
'pgadmin:tool:show',
|
||||||
`${BROWSER_PANELS.PSQL_TOOL}_${transId}`,
|
`${BROWSER_PANELS.PSQL_TOOL}_${transId}`,
|
||||||
panelUrl,
|
panelUrl,
|
||||||
{title: escapedTitle, db: db_label},
|
{title: panelTitle, db: db_label},
|
||||||
{title: panelTitle, icon: 'pg-font-icon icon-terminal', manualClose: false, renamable: true},
|
{title: panelTitle, icon: 'pg-font-icon icon-terminal', manualClose: false, renamable: true},
|
||||||
Boolean(open_new_tab?.includes('psql_tool'))
|
Boolean(open_new_tab?.includes('psql_tool'))
|
||||||
);
|
);
|
||||||
|
@ -190,7 +189,7 @@ export default class Psql {
|
||||||
<PgAdminProvider value={pgAdmin}>
|
<PgAdminProvider value={pgAdmin}>
|
||||||
<ModalProvider>
|
<ModalProvider>
|
||||||
<NotifierProvider pgAdmin={pgAdmin} pgWindow={pgWindow} />
|
<NotifierProvider pgAdmin={pgAdmin} pgWindow={pgWindow} />
|
||||||
<PsqlComponent params={params} pgAdmin={pgAdmin} />
|
<PsqlComponent params={JSON.parse(params)} pgAdmin={pgAdmin} />
|
||||||
</ModalProvider>
|
</ModalProvider>
|
||||||
</PgAdminProvider>
|
</PgAdminProvider>
|
||||||
</Theme>
|
</Theme>
|
||||||
|
|
|
@ -332,12 +332,14 @@ def panel(trans_id):
|
||||||
params['layout'] = get_setting('SQLEditor/Layout')
|
params['layout'] = get_setting('SQLEditor/Layout')
|
||||||
params['macros'] = get_user_macros()
|
params['macros'] = get_user_macros()
|
||||||
params['is_desktop_mode'] = current_app.PGADMIN_RUNTIME
|
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:
|
if 'database_name' in params:
|
||||||
params['database_name'] = underscore_escape(params['database_name'])
|
params['database_name'] = underscore_escape(params['database_name'])
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"sqleditor/index.html",
|
"sqleditor/index.html",
|
||||||
title=underscore_unescape(params['title']),
|
title=underscore_escape(params['title']),
|
||||||
params=json.dumps(params),
|
params=json.dumps(params),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ export default class SQLEditor {
|
||||||
'pgadmin:tool:show',
|
'pgadmin:tool:show',
|
||||||
`${BROWSER_PANELS.QUERY_TOOL}_${trans_id}`,
|
`${BROWSER_PANELS.QUERY_TOOL}_${trans_id}`,
|
||||||
panel_url,
|
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},
|
{title: panel_title, icon: icon, tooltip: tooltip, renamable: true},
|
||||||
Boolean(open_new_tab?.includes('qt'))
|
Boolean(open_new_tab?.includes('qt'))
|
||||||
);
|
);
|
||||||
|
@ -229,7 +229,7 @@ export default class SQLEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadComponent(container, params) {
|
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();
|
pgAdmin.Browser.keyboardNavigation.init();
|
||||||
await listenPreferenceBroadcast();
|
await listenPreferenceBroadcast();
|
||||||
const root = ReactDOM.createRoot(container);
|
const root = ReactDOM.createRoot(container);
|
||||||
|
|
|
@ -448,6 +448,13 @@ export default function QueryToolDataGrid({columns, rows, totalRowCount, dataCha
|
||||||
rowIdx
|
rowIdx
|
||||||
}, true);
|
}, 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}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue