Browse Source

fix: include ip block list & remove type

feat/0523-export-schema
Wing-Kam Wong 2 years ago committed by Raju Udava
parent
commit
eecf630e59
  1. 8
      packages/nc-gui/components/import/QuickImport.vue
  2. 3
      packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js
  3. 23
      packages/nocodb/src/lib/meta/api/utilApis.ts

8
packages/nc-gui/components/import/QuickImport.vue

@ -67,8 +67,9 @@
:rules="
[
v => !!v || $t('general.required'),
v => quickImportType === 'excel' ?
(/.*\.(xls|xlsx|xlsm|ods|ots)/.test(v) || errorMessages.importExcel) :
v => !(/(10)(\.([2]([0-5][0-5]|[01234][6-9])|[1][0-9][0-9]|[1-9][0-9]|[0-9])){3}|(172)\.(1[6-9]|2[0-9]|3[0-1])(\.(2[0-4][0-9]|25[0-5]|[1][0-9][0-9]|[1-9][0-9]|[0-9])){2}|(192)\.(168)(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){2}|(0.0.0.0)|localhost?/g).test(v) || errorMessages.ipBlockList,
v => quickImportType === 'excel' ?
(/.*\.(xls|xlsx|xlsm|ods|ots)/.test(v) || errorMessages.importExcel) :
(/.*\.(csv)/.test(v) || errorMessages.importCSV),
]"
/>
@ -222,7 +223,8 @@ export default {
filename: '',
errorMessages: {
importExcel: "Target file is not an accepted file type. The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots!",
importCSV: "Target file is not an accepted file type. The accepted file type is .csv!"
importCSV: "Target file is not an accepted file type. The accepted file type is .csv!",
ipBlockList: "IP Not allowed!"
}
}
},

3
packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js

@ -13,8 +13,7 @@ export default class ExcelUrlTemplateAdapter extends ExcelTemplateAdapter {
async init() {
const data = await this.$api.utils.axiosRequestMake({
apiMeta: {
url: this.url,
type: this.quickImportType === 'excel' ? 'excelUrl' : 'csvUrl'
url: this.url
}
})
this.excelData = data.data

23
packages/nocodb/src/lib/meta/api/utilApis.ts

@ -60,11 +60,9 @@ export async function releaseVersion(_req: Request, res: Response) {
res.json(result);
}
async function _axiosRequestMake(req: Request, res: Response, type: string) {
async function _axiosRequestMake(req: Request, res: Response) {
const { apiMeta } = req.body;
if (type === 'csvUrl' || type === 'excelUrl') {
apiMeta.responseType = 'arraybuffer';
}
if (apiMeta?.body) {
try {
apiMeta.body = JSON.parse(apiMeta.body);
@ -111,12 +109,21 @@ async function _axiosRequestMake(req: Request, res: Response, type: string) {
export async function axiosRequestMake(req: Request, res: Response) {
const {
apiMeta: { type }
apiMeta: { url }
} = req.body;
if (type === 'csvUrl' || type === 'excelUrl') {
return await _axiosRequestMake(req, res, type);
const isExcelImport = /.*\.(xls|xlsx|xlsm|ods|ots)/;
const isCSVImport = /.*\.(csv)/;
const ipBlockList = /(10)(\.([2]([0-5][0-5]|[01234][6-9])|[1][0-9][0-9]|[1-9][0-9]|[0-9])){3}|(172)\.(1[6-9]|2[0-9]|3[0-1])(\.(2[0-4][0-9]|25[0-5]|[1][0-9][0-9]|[1-9][0-9]|[0-9])){2}|(192)\.(168)(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){2}|(0.0.0.0)|localhost?/g;
if (
ipBlockList.test(url) ||
(!isCSVImport.test(url) && !isExcelImport.test(url))
) {
return res.json({});
}
if (isCSVImport || isExcelImport) {
req.body.apiMeta.responseType = 'arraybuffer';
}
return res.json({});
return await _axiosRequestMake(req, res);
}
export default router => {

Loading…
Cancel
Save