wagtail-enap-designsystem 1.2.1.197__py3-none-any.whl → 1.2.1.198__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2081,7 +2081,7 @@ class FormularioPage(Page):
2081
2081
  return conditional_data
2082
2082
 
2083
2083
 
2084
- # SUBSTITUIR também o método get_context para incluir os dados condicionais corretos
2084
+ # dados condicionais
2085
2085
 
2086
2086
  def get_context(self, request, *args, **kwargs):
2087
2087
  """Adiciona contexto personalizado - VERSÃO CORRIGIDA"""
@@ -2131,7 +2131,7 @@ class FormularioPage(Page):
2131
2131
  if not self.should_process_conditional_field(block, form_data, request):
2132
2132
  continue
2133
2133
 
2134
- # NOVA VALIDAÇÃO DE SEGURANÇA - APLICAR A TODOS OS CAMPOS DE TEXTO
2134
+ # VALIDAÇÃO DE SEGURANÇA - APLICAR A TODOS OS CAMPOS DE TEXTO
2135
2135
  if isinstance(value, str) and value.strip():
2136
2136
  try:
2137
2137
  if block.block_type == 'email_field':
@@ -57,4 +57,5 @@ def validate_email_field(value):
57
57
  raise ValidationError(
58
58
  _('Email contém comandos não permitidos.'),
59
59
  code='sql_command_in_email'
60
- )
60
+ )
61
+
@@ -2091,17 +2091,29 @@ function getFileIcon(filename) {
2091
2091
  function cleanInput(input, originalValue) {
2092
2092
  let cleanValue = originalValue;
2093
2093
 
2094
- // 1. Primeiro remover caracteres especiais
2094
+ // 1. Identificar o tipo de campo
2095
2095
  const fieldName = (input.name || input.id || '').toLowerCase();
2096
2096
  const isEmailField = fieldName.includes('email') || input.type === 'email';
2097
+ const isTextareaField = input.tagName.toLowerCase() === 'textarea' || fieldName.includes('textarea_field');
2097
2098
 
2099
+ // 2. Aplicar limpeza específica para cada tipo de campo
2098
2100
  if (isEmailField) {
2101
+ // Para campos de email, permitir @ e pontos
2099
2102
  cleanValue = originalValue.replace(/[^a-zA-Z0-9@.\-_]/g, '');
2103
+ } else if (isTextareaField) {
2104
+ // Para campos textarea, permitir mais caracteres, mas remover scripts e código malicioso
2105
+ // Remover tags <script>, <iframe>, javascript: etc.
2106
+ cleanValue = originalValue
2107
+ .replace(/<script[\s\S]*?<\/script>/gi, '') // Remove tags script
2108
+ .replace(/<iframe[\s\S]*?<\/iframe>/gi, '') // Remove tags iframe
2109
+ .replace(/javascript:/gi, '') // Remove javascript:
2110
+ .replace(/on\w+\s*=/gi, ''); // Remove manipuladores de eventos onclick, onload, etc.
2100
2111
  } else {
2112
+ // Para outros campos de texto, manter a limpeza original
2101
2113
  cleanValue = originalValue.replace(/[^a-zA-Z0-9À-ÿ\s.\-]/g, '');
2102
2114
  }
2103
2115
 
2104
- // 2. Depois verificar comandos SQL
2116
+ // 3. Verificar comandos SQL para TODOS os tipos de campos
2105
2117
  const sqlCheck = containsSqlCommands(cleanValue);
2106
2118
  if (sqlCheck.found) {
2107
2119
  // Remover a palavra SQL encontrada
@@ -2180,25 +2192,39 @@ function getFileIcon(filename) {
2180
2192
  const value = input.value.trim();
2181
2193
  if (!value) return;
2182
2194
 
2183
- // Verificar caracteres proibidos
2184
- const prohibitedChars = /['";\\<>]/;
2195
+ const isTextarea = input.tagName.toLowerCase() === 'textarea' ||
2196
+ (input.name || '').toLowerCase().includes('textarea_field');
2197
+
2198
+ // Verificação de conteúdo malicioso
2199
+ let hasProhibitedContent = false;
2200
+
2201
+ if (isTextarea) {
2202
+ // Para textareas, verificar JavaScript malicioso
2203
+ hasProhibitedContent = /<script|<iframe|javascript:|on\w+\s*=/i.test(value);
2204
+ } else {
2205
+ // Para outros campos, verificação mais rigorosa
2206
+ hasProhibitedContent = /['";\\<>]/i.test(value);
2207
+ }
2208
+
2209
+ // Verificação de comandos SQL para todos os campos
2185
2210
  const sqlCheck = containsSqlCommands(value);
2186
2211
 
2187
- if (prohibitedChars.test(value) || sqlCheck.found) {
2212
+ if (hasProhibitedContent || sqlCheck.found) {
2188
2213
  console.warn('⚠️ Conteúdo proibido:', {
2189
2214
  campo: input.name,
2190
2215
  valor: value,
2191
2216
  sql: sqlCheck.found ? sqlCheck.command : 'não',
2192
- caracteres: prohibitedChars.test(value)
2217
+ caracteres: hasProhibitedContent
2193
2218
  });
2194
2219
 
2195
2220
  hasProhibited = true;
2196
2221
  input.style.borderColor = 'red';
2197
2222
  input.style.backgroundColor = '#ffe6e6';
2198
2223
 
2199
- if (!hasProhibited) {
2224
+ if (!input.hasBeenFocused) {
2200
2225
  input.focus();
2201
2226
  input.scrollIntoView({ behavior: 'smooth', block: 'center' });
2227
+ input.hasBeenFocused = true;
2202
2228
  }
2203
2229
  }
2204
2230
  });
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wagtail-enap-designsystem
3
- Version: 1.2.1.197
3
+ Version: 1.2.1.198
4
4
  Summary: Módulo de componentes utilizado nos portais ENAP, desenvolvido com Wagtail + CodeRedCMS
5
5
  Author: Renan Campos
6
6
  Author-email: renan.oliveira@enap.gov.br
@@ -11,10 +11,10 @@ enap_designsystem/blocks/__init__.py,sha256=jtlNAEIsIo_KipwQcUMVQuR4vdt4AjrLjag6
11
11
  enap_designsystem/blocks/base_blocks.py,sha256=ZuqVWn4PEAvD3pKM1ST7wjo4lwv98ooen_rs15rRJbg,10866
12
12
  enap_designsystem/blocks/chatbot_blocks.py,sha256=YeCznrXMbFa9MP9vjdTYl53ZhKsywkGOXvFK2bwcqW0,1133
13
13
  enap_designsystem/blocks/content_blocks.py,sha256=X8Ldf6eMRhjhIYxC2rLssb151r2iFFFQ8XxwPpBbjyI,17282
14
- enap_designsystem/blocks/form.py,sha256=rQ_KfMgafbA7NSBGneUsregEhphKCxfNh4rG8s6FEWI,90007
14
+ enap_designsystem/blocks/form.py,sha256=fVohUAc1JWJZkFiEuc7ar3HTje-lqUj_n0Qcmxv7luU,89937
15
15
  enap_designsystem/blocks/html_blocks.py,sha256=YE8xNA8HQ5iavP_UIlJrhwIUpgtfVMQTP3XVk2dg4J0,281986
16
16
  enap_designsystem/blocks/layout_blocks.py,sha256=qND7aUna3VL3PK7sAKE7PiPfSvahMwHK_lZoKUkudeo,23461
17
- enap_designsystem/blocks/security.py,sha256=cOdLix8cOkjV-Ef-NMjrVid0e3u5uxGNPZk8S7J-rr0,2178
17
+ enap_designsystem/blocks/security.py,sha256=WysHpW0HtZoQTGy9YilYrgtWxUcMinq9vN8KkJxJ7KI,2191
18
18
  enap_designsystem/blocks/semana_blocks.py,sha256=AfaxJQmStvFkw6yrPeKyZurC6jzCxWxyzmdny_pret0,70929
19
19
  enap_designsystem/blocks/semana_inovacao.py,sha256=iPwsYG4oIZIIGR9zyu7bCTuVGn-E8-28KjPnI-SNIAs,47038
20
20
  enap_designsystem/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -834,7 +834,7 @@ enap_designsystem/templates/enap_designsystem/blocks/suap/apisuap_courses_block.
834
834
  enap_designsystem/templates/enap_designsystem/blocks/suap/suap_courses_block.html,sha256=_7AC4WBH4qCXmwlKqnRLbPeUnAopLGeKUIrd6FYcvps,16036
835
835
  enap_designsystem/templates/enap_designsystem/blocks/suap/suap_events_block.html,sha256=mL2DFQeAuDIx_GyCoEURKmME-Mmd-zQ_NZkO7YW9Z2k,20182
836
836
  enap_designsystem/templates/enap_designsystem/form_templates/form_report.html,sha256=WXf4HgNQY0M6zZ-tERqf01mHbGflqWXT96RaJYjCxFA,16081
837
- enap_designsystem/templates/enap_designsystem/form_templates/formulario_page.html,sha256=kDdB_pSFU5_Z4Kh81oSyItDs6xy6U88rJFTfFv91ld0,64367
837
+ enap_designsystem/templates/enap_designsystem/form_templates/formulario_page.html,sha256=eu0GY3if-UgyklcdnCSiaU6mxBZGsPIjr8aVuhu_DoI,65974
838
838
  enap_designsystem/templates/enap_designsystem/form_templates/formulario_page_landing.html,sha256=2dVaFwunBrHsq0b3rP1buEFxO6hfplFH3-GoUuyLJPo,7598
839
839
  enap_designsystem/templates/enap_designsystem/form_templates/formulario_page_success.html,sha256=jFE9GYRxy19ha37pVvucEVYDKTeU56Nav2Fd3phqmZ4,9363
840
840
  enap_designsystem/templates/enap_designsystem/form_templates/home_page.html,sha256=BYV5TV6xp0uY3SWtNsAf8p-aDqPiHfM8j4pWbqTUV2M,42329
@@ -934,8 +934,8 @@ enap_designsystem/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
934
934
  enap_designsystem/utils/decorators.py,sha256=aq6SbLn0LcH2rfE3ZFit8jkD7pSx9fLVBUUwVB747hg,335
935
935
  enap_designsystem/utils/services.py,sha256=6dG5jLSbwH49jpZV9ZNpWlaZqI49gTlwlr1vaerxdiU,5824
936
936
  enap_designsystem/utils/sso.py,sha256=vjAuoYgoLeQAa_dkkyQ6-LmHvKMaVCxizNFpe5y3iUA,1145
937
- wagtail_enap_designsystem-1.2.1.197.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
938
- wagtail_enap_designsystem-1.2.1.197.dist-info/METADATA,sha256=jG3qmGYb67pVJdRwrgZUddsSL01qshapx5nXSdoaQJ8,3651
939
- wagtail_enap_designsystem-1.2.1.197.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
940
- wagtail_enap_designsystem-1.2.1.197.dist-info/top_level.txt,sha256=RSFgMASxoA-hVftm5i4Qd0rArlX4Dq08lLv5G4sYD-g,18
941
- wagtail_enap_designsystem-1.2.1.197.dist-info/RECORD,,
937
+ wagtail_enap_designsystem-1.2.1.198.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
938
+ wagtail_enap_designsystem-1.2.1.198.dist-info/METADATA,sha256=UE_U52AOXSsFTjUdp0hsg2oKflC4Ju8u0FT2ew0f9Oo,3651
939
+ wagtail_enap_designsystem-1.2.1.198.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
940
+ wagtail_enap_designsystem-1.2.1.198.dist-info/top_level.txt,sha256=RSFgMASxoA-hVftm5i4Qd0rArlX4Dq08lLv5G4sYD-g,18
941
+ wagtail_enap_designsystem-1.2.1.198.dist-info/RECORD,,