Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-68724

O bloco Linha do Tempo está gerando erro no painel quando atividades contém caractere TAB / block_timeline can cause JSON parse error on dashboard when activities are saved with TAB character

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Deferred
    • Affects Version/s: 3.7.6, 3.8.3
    • Fix Version/s: None
    • Component/s: Blocks, Dashboard (My home)
    • Labels:
      None
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE

      Description

      Ao carregar o painel (/my), o bloco da linha do tempo exibe a lista de atividades, mas não consegue tratar atividades que tenham caractere TAB nos nomes das atividades, e um erro de análise ajax JSON será exibido.

      When loading the Dashboard (/my), the block_timeline displays the list of activities, but cannot handle activities that have a TAB character in the activity names, and a JSON parsing error will be displayed.

      SyntaxError: Unexpected token 	 in JSON at position 31
          at JSON.parse (<anonymous>)
          at z.stringHelper (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:74:3408)
          at z.<anonymous> (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:74:4319)
          at n.renderSection (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:23:5343)
          at n.renderTokens (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:23:4530)
          at n.renderPartial (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:23:5678)
          at n.renderTokens (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:23:4623)
          at n.renderSection (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:23:5072)
          at n.renderTokens (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:23:4530)
          at n.renderPartial (http://localhost/moodle/lib/requirejs.php/1589227188/core/first.js:23:5678)
      

      Eu tentei verificar qual seria esse caractere que aparece na posição 31 em um simulador regex online (https://regexr.com/). Foi identificado como caractere TAB (\t).

      I tried to check which character would appear at position 31 and in an online regex simulator (https://regexr.com/). It was identified as a TAB (\t) character.

      Depois seguindo a linha de raciocínio do erro reportado em #MDL-65183, o qual reportava erro similar porém com caractere de quebra de linha. Tentei adicionar um \t ao arquivo lib/amd/src/templates.js, algo do tipo:

      Then following the train of thought of report #MDL-65183, which reported a similar error but with a newline characteres. I tried to add a \t to the lib/amd/src/templates.js file. Something like that:

      .replace(/(\r\n\t|\r|\n|\t)/g, '&#x0a;');
      

      Porém não obtive sucesso. O erro continua aparecendo.

      But I was not successful. The error keeps showing up.

       

      Para simular o erro: Use um curso de teste, ative o Acompanhamento de conclusão nas configurações do curso e inscreva seu usuário (de preferência no papel de professor), para que possa criar uma atividade e para que a atividade do curso apareça no painel. Crie a atividade com caractere TAB no nome da atividade. Para isso use um editor de texto externo e a o recurso copiar e colar.

      To simulate the error: Use a test course, activate the Completion tracking in the course settings and enroll your user (preferably as a teacher), so that you can create an activity and for the course activity appear on the panel. Create the activity with TAB character in the activity name. To do this, use an external text editor and copy and paste.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              douglas.nantes Douglas Nantes Gualberto
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: