platform icon indicating copy to clipboard operation
platform copied to clipboard

Cannot view table with special characters

Open aeberhart opened this issue 1 year ago β€’ 7 comments

aeberhart avatar Feb 24 '24 15:02 aeberhart

The issue only happens with " " (space) characters in the resource name. Other special characters work fine. In this case, react admin cannot map the browser route to the resource.

Just tested with the latest version of react-admin (4.16.11). The behaviour changed but was still buggy.

Asked in the RA admin discord of there were any rules for choosing / escaping resource names

aeberhart avatar Feb 27 '24 20:02 aeberhart

postpone RA update

maybe replace table names containing space with _

aeberhart avatar Mar 11 '24 10:03 aeberhart

we should remove the upload special handling once the underlying RA issue is fixed

aeberhart avatar Mar 26 '24 10:03 aeberhart

react admin behaves as follows w.r.t. special characters in resource names:

  • / is not escaped - this conflicts with the DJ parsing logic though
  • "hash" is escaped to %23, however the link to instance pages is broken because the hyperlink does not escape # (this is an issue in RA)
  • % is escaped to %25, but the links are also broken
  • ? does not work at all
  • any other special character is escaped (for instance db/a b becomes db/a%20b)

aeberhart avatar May 16 '24 08:05 aeberhart

RA useCreatePath:

                return removeDoubleSlashes(
                    `${basename}/${resource}/${encodeURIComponent(id)}/show`
                );

aeberhart avatar May 16 '24 08:05 aeberhart

test code

const AdminApp = () => (
    <Admin dataProvider={dataProvider}>
        <Resource name="ΓΆ" list={LIST} edit={EDIT} />
        <Resource name="a!b" list={LIST} edit={EDIT} />
        <Resource name="a b" list={LIST} edit={EDIT} />
        <Resource name="a/b" list={LIST} edit={EDIT} />
        <Resource name="a%2Fb" list={LIST} edit={EDIT} />
        <Resource name="a@b" list={LIST} edit={EDIT} />
        <Resource name="a\b" list={LIST} edit={EDIT} />
        <Resource name="a'b" list={LIST} edit={EDIT} />
        <Resource name='a"b' list={LIST} edit={EDIT} />
        <Resource name="a:b" list={LIST} edit={EDIT} />
        <Resource name="a+b" list={LIST} edit={EDIT} />

        <Resource name="a#b" list={LIST} edit={EDIT} />
        <Resource name="a?b" list={LIST} edit={EDIT} />
        <Resource name="a%b" list={LIST} edit={EDIT} />
        <Resource name="a%23b" list={LIST} edit={EDIT} />
    </Admin>
);

export const LIST = () => {
    return <p>{useResourceContext()}</p>
}
export const EDIT = () => {
    return <p>{useResourceContext() + ' - ' + useGetRecordId()}</p>
}

aeberhart avatar May 16 '24 09:05 aeberhart

TODO still: special handling for tables that have # in their resource name

  • table FK references
  • links widget
  • handling of djLabel in those cases

aeberhart avatar May 16 '24 10:05 aeberhart