Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix form values sanitization messes with JSON values #4103

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

fzaninotto
Copy link
Member

Closes #4037

@djhi djhi merged commit d73cdb5 into master Dec 3, 2019
@djhi djhi deleted the fix-json-input-parsing-bug branch December 3, 2019 11:40
@wmwart
Copy link

wmwart commented Dec 4, 2019

@djhi, the test you used will pass and if you don’t make a change.
As I wrote the problem with objects that contain id or lists in their keys.
Here is what my json gives out with these changes:

{
   group: [
      {
         group: [
            {
               uaid: [ "10", "11", "12", "13", "14", "15", "16", "17", "18" ],
               group: [
                  {
                     uaid: [ "110", "111", "112", "113" ],
                     name: "Настройка параметров",
                     id: "2"
                  },
                  {
                     uaid: [ "14", "10", "120", "121", "122", "123", "124", "125" ],
                     name: "Синхронизация Vст",
                     id: "3"
                  }
               ],
               name: "V стандарт",
               id: "1"
            },
            {
               group: [
                  {
                     name: "Настройка параметров",
                     id: "5"
                  },
                  {
                     name: "Синхронизация Vр",
                     id: "6"
                  }
               ],
               name: "V рабочий",
               id: "4"
            },
            {
               uaid: [  "30", "37", "38", "39", "311", "312", "313", "31", "32", "33", "34", "35", "36" ],
               name: "Давление",
               id: "7"
            },
            {
               uaid: [ "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "400" ],
               name: "Температура",
               id: "8"
            },
            {
               name: "Преобразование",
               id: "9"
            },
            {
               uaid: [ "1000", "1001", "1002", "1005" ],
               group: [
                  {
                     name: "Месячный архив 1",
                     id: "101"
                  },
                  {
                     name: "Месячный архив 2",
                     id: "102"
                  },
                  {
                     name: "Суточный архив",
                     id: "103"
                  },
                  {
                     name: "Интервальный архив",
                     id: "104"
                  }
               ],
               name: "Архив",
               id: "10"
            },
            {
               uaid: [ "1100",  "1101", "1102", "1103", "1104" ],
               group: [
                  {
                     name: "Журнал событий",
                     id: "111"
                  },
                  {
                     name: "Журнал изменений",
                     id: "112"
                  }
               ],
               name: "Статус",
               id: "11"
            },
            {
               name: "Прибор",
               id: "12"
            },
            {
               name: "Сервис",
               id: "13"
            }
         ],
         name: "EK270-menu",
         id: "0"
      }
   ],
   name: "EK280"
}

output:

{
  group: [
    {
      group: [
        {
          uaid: [
            '10',
            '11',
            '12',
            '13',
            '14',
            '15',
            '16',
            '17',
            '18'
          ],
          group: [
            {
              uaid: [
                '110',
                '111',
                '112',
                '113'
              ],
              name: 'Настройка параметров',
              id: '2'
            },
            {
              uaid: [
                '14',
                '10',
                '120',
                '121',
                '122',
                '123',
                '124',
                '125'
              ],
              name: 'Синхронизация Vст',
              id: '3'
            }
          ],
          groupIds: [
            '2',
            '3'
          ],
          name: 'V стандарт',
          id: '1'
        },
        {
          group: [
            {
              name: 'Настройка параметров',
              id: '5'
            },
            {
              name: 'Синхронизация Vр',
              id: '6'
            }
          ],
          groupIds: [
            '5',
            '6'
          ],
          name: 'V рабочий',
          id: '4'
        },
        {
          uaid: [
            '30',
            '37',
            '38',
            '39',
            '311',
            '312',
            '313',
            '31',
            '32',
            '33',
            '34',
            '35',
            '36'
          ],
          name: 'Давление',
          id: '7'
        },
        {
          uaid: [
            '40',
            '41',
            '42',
            '43',
            '44',
            '45',
            '46',
            '47',
            '48',
            '49',
            '400'
          ],
          name: 'Температура',
          id: '8'
        },
        {
          name: 'Преобразование',
          id: '9'
        },
        {
          uaid: [
            '1000',
            '1001',
            '1002',
            '1005'
          ],
          group: [
            {
              name: 'Месячный архив 1',
              id: '101'
            },
            {
              name: 'Месячный архив 2',
              id: '102'
            },
            {
              name: 'Суточный архив',
              id: '103'
            },
            {
              name: 'Интервальный архив',
              id: '104'
            }
          ],
          groupIds: [
            '101',
            '102',
            '103',
            '104'
          ],
          name: 'Архив',
          id: '10'
        },
        {
          uaid: [
            '1100',
            '1101',
            '1102',
            '1103',
            '1104'
          ],
          group: [
            {
              name: 'Журнал событий',
              id: '111'
            },
            {
              name: 'Журнал изменений',
              id: '112'
            }
          ],
          groupIds: [
            '111',
            '112'
          ],
          name: 'Статус',
          id: '11'
        },
        {
          name: 'Прибор',
          id: '12'
        },
        {
          name: 'Сервис',
          id: '13'
        }
      ],
      groupIds: [
        '1',
        '4',
        '7',
        '8',
        '9',
        '10',
        '11',
        '12',
        '13'
      ],
      name: 'EK270-menu',
      id: '0'
    }
  ],
  groupIds: '',
  name: 'EK280'
}

ra added groupIds parameter to lists.

@fzaninotto
Copy link
Member Author

Could you reduce the problem to a simpler JSON?

@wmwart
Copy link

wmwart commented Dec 4, 2019

{
  group: [
    {
      uaid: [
        '110',
        '111'
      ],
      name: 'Настройка  параметров',
      id: '2'
    },
    {
      uaid: [
        '14',
        '10'
      ],
      name: 'Синхронизация Vст',
      id: '3'
    }
  ],
  name: 'V стандарт',
  id: '1'
}

==>

{
  group: [
    {
      uaid: [
        '110',
        '111'
      ],
      name: 'Настройка  параметров',
      id: '2'
    },
    {
      uaid: [
        '14',
        '10'
      ],
      name: 'Синхронизация Vст',
      id: '3'
    }
  ],
  groupIds: '',
  name: 'V стандарт',
  id: '1'
}

ra added groupIds parameter after list.

@wmwart
Copy link

wmwart commented Dec 18, 2019

@fzaninotto, is it thrown?

@dorthwein
Copy link

dorthwein commented Dec 8, 2021

So this is still happening particularly with GeoJson feature collections which can go several layers down ;( I have a hunch in my use case i'll need to create my own Form Component.

--- UPDATE ---
The issue is in the ra-simple-graphql provider

@djhi
Copy link
Collaborator

djhi commented Dec 9, 2021

Can you open a new issue following the issue template please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with json type Inputs
4 participants