Fixing issue introduced by fix for #7683 - encoding the query string caused handlebars statements to break, this rectifies that.
This commit is contained in:
parent
e4185e98aa
commit
fc8dc9f176
|
@ -47,7 +47,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
top: 15px;
|
top: 15px;
|
||||||
z-index: 100;
|
z-index: 200;
|
||||||
width: 160px;
|
width: 160px;
|
||||||
}
|
}
|
||||||
.icon {
|
.icon {
|
||||||
|
|
|
@ -9,14 +9,14 @@ import {
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import {
|
import {
|
||||||
queries as queriesStores,
|
queries as queriesStores,
|
||||||
tables as tablesStore,
|
|
||||||
roles as rolesStore,
|
roles as rolesStore,
|
||||||
|
tables as tablesStore,
|
||||||
} from "stores/backend"
|
} from "stores/backend"
|
||||||
import {
|
import {
|
||||||
makePropSafe,
|
|
||||||
isJSBinding,
|
|
||||||
decodeJSBinding,
|
decodeJSBinding,
|
||||||
encodeJSBinding,
|
encodeJSBinding,
|
||||||
|
isJSBinding,
|
||||||
|
makePropSafe,
|
||||||
} from "@budibase/string-templates"
|
} from "@budibase/string-templates"
|
||||||
import { TableNames } from "../constants"
|
import { TableNames } from "../constants"
|
||||||
import { JSONUtils } from "@budibase/frontend-core"
|
import { JSONUtils } from "@budibase/frontend-core"
|
||||||
|
@ -118,8 +118,7 @@ export const readableToRuntimeMap = (bindings, ctx) => {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
return Object.keys(ctx).reduce((acc, key) => {
|
return Object.keys(ctx).reduce((acc, key) => {
|
||||||
let parsedQuery = readableToRuntimeBinding(bindings, ctx[key])
|
acc[key] = readableToRuntimeBinding(bindings, ctx[key])
|
||||||
acc[key] = parsedQuery
|
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
@ -132,8 +131,7 @@ export const runtimeToReadableMap = (bindings, ctx) => {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
return Object.keys(ctx).reduce((acc, key) => {
|
return Object.keys(ctx).reduce((acc, key) => {
|
||||||
let parsedQuery = runtimeToReadableBinding(bindings, ctx[key])
|
acc[key] = runtimeToReadableBinding(bindings, ctx[key])
|
||||||
acc[key] = parsedQuery
|
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { IntegrationTypes } from "constants/backend"
|
import { IntegrationTypes } from "constants/backend"
|
||||||
|
import { findHBSBlocks } from "@budibase/string-templates"
|
||||||
|
|
||||||
export function schemaToFields(schema) {
|
export function schemaToFields(schema) {
|
||||||
const response = {}
|
const response = {}
|
||||||
|
@ -31,7 +32,8 @@ export function breakQueryString(qs) {
|
||||||
let paramObj = {}
|
let paramObj = {}
|
||||||
for (let param of params) {
|
for (let param of params) {
|
||||||
const split = param.split("=")
|
const split = param.split("=")
|
||||||
paramObj[split[0]] = split.slice(1).join("=")
|
console.log(split[1])
|
||||||
|
paramObj[split[0]] = decodeURIComponent(split.slice(1).join("="))
|
||||||
}
|
}
|
||||||
return paramObj
|
return paramObj
|
||||||
}
|
}
|
||||||
|
@ -46,7 +48,19 @@ export function buildQueryString(obj) {
|
||||||
if (str !== "") {
|
if (str !== "") {
|
||||||
str += "&"
|
str += "&"
|
||||||
}
|
}
|
||||||
str += `${key}=${encodeURIComponent(value || "")}`
|
const bindings = findHBSBlocks(value)
|
||||||
|
let count = 0
|
||||||
|
const bindingMarkers = {}
|
||||||
|
bindings.forEach(binding => {
|
||||||
|
const marker = `BINDING...${count++}`
|
||||||
|
value = value.replace(binding, marker)
|
||||||
|
bindingMarkers[marker] = binding
|
||||||
|
})
|
||||||
|
let encoded = encodeURIComponent(value || "")
|
||||||
|
Object.entries(bindingMarkers).forEach(([marker, binding]) => {
|
||||||
|
encoded = encoded.replace(marker, binding)
|
||||||
|
})
|
||||||
|
str += `${key}=${encoded}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
|
|
|
@ -347,6 +347,7 @@
|
||||||
const datasourceUrl = datasource?.config.url
|
const datasourceUrl = datasource?.config.url
|
||||||
const qs = query?.fields.queryString
|
const qs = query?.fields.queryString
|
||||||
breakQs = restUtils.breakQueryString(qs)
|
breakQs = restUtils.breakQueryString(qs)
|
||||||
|
console.log(breakQs)
|
||||||
breakQs = runtimeToReadableMap(mergedBindings, breakQs)
|
breakQs = runtimeToReadableMap(mergedBindings, breakQs)
|
||||||
|
|
||||||
const path = query.fields.path
|
const path = query.fields.path
|
||||||
|
@ -708,6 +709,7 @@
|
||||||
.url-block {
|
.url-block {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--spacing-s);
|
gap: var(--spacing-s);
|
||||||
|
z-index: 200;
|
||||||
}
|
}
|
||||||
.verb {
|
.verb {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
|
@ -80,16 +80,15 @@ const addSessionAttributesToUser = ctx => {
|
||||||
ctx.body.csrfToken = ctx.user.csrfToken
|
ctx.body.csrfToken = ctx.user.csrfToken
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const sanitiseUserUpdate = ctx => {
|
||||||
* Remove the attributes that are session based from the current user,
|
const allowed = ["firstName", "lastName", "password", "forceResetPassword"]
|
||||||
* so that stale values are not written to the db
|
const resp = {}
|
||||||
*/
|
for (let [key, value] of Object.entries(ctx.request.body)) {
|
||||||
const removeSessionAttributesFromUser = ctx => {
|
if (allowed.includes(key)) {
|
||||||
delete ctx.request.body.csrfToken
|
resp[key] = value
|
||||||
delete ctx.request.body.account
|
}
|
||||||
delete ctx.request.body.accountPortalAccess
|
}
|
||||||
delete ctx.request.body.budibaseAccess
|
return resp
|
||||||
delete ctx.request.body.license
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getSelf = async ctx => {
|
exports.getSelf = async ctx => {
|
||||||
|
@ -117,10 +116,12 @@ exports.updateSelf = async ctx => {
|
||||||
const db = getGlobalDB()
|
const db = getGlobalDB()
|
||||||
const user = await db.get(ctx.user._id)
|
const user = await db.get(ctx.user._id)
|
||||||
let passwordChange = false
|
let passwordChange = false
|
||||||
if (ctx.request.body.password) {
|
|
||||||
|
const userUpdateObj = sanitiseUserUpdate(ctx)
|
||||||
|
if (userUpdateObj.password) {
|
||||||
// changing password
|
// changing password
|
||||||
passwordChange = true
|
passwordChange = true
|
||||||
ctx.request.body.password = await hash(ctx.request.body.password)
|
userUpdateObj.password = await hash(userUpdateObj.password)
|
||||||
// Log all other sessions out apart from the current one
|
// Log all other sessions out apart from the current one
|
||||||
await platformLogout({
|
await platformLogout({
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -128,14 +129,10 @@ exports.updateSelf = async ctx => {
|
||||||
keepActiveSession: true,
|
keepActiveSession: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// don't allow sending up an ID/Rev, always use the existing one
|
|
||||||
delete ctx.request.body._id
|
|
||||||
delete ctx.request.body._rev
|
|
||||||
removeSessionAttributesFromUser(ctx)
|
|
||||||
|
|
||||||
const response = await db.put({
|
const response = await db.put({
|
||||||
...user,
|
...user,
|
||||||
...ctx.request.body,
|
...userUpdateObj,
|
||||||
})
|
})
|
||||||
await userCache.invalidateUser(user._id)
|
await userCache.invalidateUser(user._id)
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
errors,
|
errors,
|
||||||
events,
|
events,
|
||||||
tenancy,
|
tenancy,
|
||||||
users as usersCore,
|
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import { checkAnyUserExists } from "../../../utilities/users"
|
import { checkAnyUserExists } from "../../../utilities/users"
|
||||||
import { groups as groupUtils } from "@budibase/pro"
|
import { groups as groupUtils } from "@budibase/pro"
|
||||||
|
@ -148,9 +147,7 @@ export const bulkDelete = async (ctx: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let response = await users.bulkDelete(userIds)
|
ctx.body = await users.bulkDelete(userIds)
|
||||||
|
|
||||||
ctx.body = response
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ctx.throw(err)
|
ctx.throw(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue