Weblate: DataError: invalid regular expression: regular expression is too complex

Created on 4 Jan 2018  路  2Comments  路  Source: WeblateOrg/weblate

Steps to reproduce

I'm not sure how to reproduce.
I have a set of html tags that when I put them individually there is no problem, but if I put them together, I get the error

Console:

...re los|\</p\>\<p\>test no garantiza que|las condiciones requeridas para|automat|para la publicaci贸n de|uso u|las finalidades solicitadas o autorizadas|relaci贸n|uso y|dichas redes|a los efectos de|o compartidos con|la p谩gina que est茅|entre test|que se|por ello se|el men煤 de|de los mismos \</p\>\<p\>test|madrid con cif b 99999999|conexion|privado quedan reservados los|la p谩gina web \<a href\="http|las fuentes que originan su|distintos|\</p\>\<p\>test recomienda la lectura|informaci贸n contenida en ninguno|terceros test no ejercer谩|comunicarlo inmediatamente a test a|partes el buen o|pueden verse modificados as铆|enlace desde su|utilicen una identidad|ello se recomienda a|confidencialidad de la informaci贸n|el acceso al|terceras|se establezcan para la|enviar o publicar|descarga y/o utiliza|links h3 div|lo expresado en|recomienda la lectura detenida|o autorizadas por el|encuentra activada la opci贸n|policial o|p la activaci贸n|siendo utilizado por el usuario|los datos facilitados ser谩n tratados|p asimismo se|como tampoco la aceptaci贸n o|domicilio en x|los contenidos que en contravenci贸n|a trav茅s de|con direcci贸n de correo electr贸nico|podr|finalidades)$') ORDER BY "trans_dictionary"."source" ASC LIMIT 21
weblate_1   | 2018-01-04 11:11:09,658 DEBG 'uwsgi' stderr output:
weblate_1   | [pid: 87|app: 0|req: 8/13] 79.152.234.129 () {44 vars in 875 bytes} [Thu Jan  4 10:44:50 2018] GET /translate/test/test-es/es/?type=all => generated 254986 bytes in 1578818 msecs (HTTP/1.1 500) 5 headers in 169 bytes (2 switches on core 0)
weblate_1   |

Traceback:

Environment:


Request Method: GET
Request URL: .../translate/test/test-es/es/?type=all

Django Version: 1.11.8
Python Version: 2.7.13
Installed Applications:
(u'django.contrib.auth',
 u'django.contrib.contenttypes',
 u'django.contrib.sessions',
 u'django.contrib.sites',
 u'django.contrib.messages',
 u'django.contrib.staticfiles',
 u'django.contrib.admin.apps.SimpleAdminConfig',
 u'django.contrib.admindocs',
 u'django.contrib.sitemaps',
 u'social_django',
 u'crispy_forms',
 u'compressor',
 u'rest_framework',
 u'rest_framework.authtoken',
 u'weblate.trans',
 u'weblate.lang',
 u'weblate.permissions',
 u'weblate.screenshots',
 u'weblate.accounts',
 u'weblate.utils',
 u'weblate.wladmin',
 u'weblate',
 u'weblate.gitexport')
Installed Middleware:
[u'django.middleware.security.SecurityMiddleware',
 u'django.contrib.sessions.middleware.SessionMiddleware',
 u'django.middleware.common.CommonMiddleware',
 u'django.middleware.locale.LocaleMiddleware',
 u'django.middleware.csrf.CsrfViewMiddleware',
 u'weblate.accounts.middleware.AuthenticationMiddleware',
 u'django.contrib.messages.middleware.MessageMiddleware',
 u'django.middleware.clickjacking.XFrameOptionsMiddleware',
 u'social_django.middleware.SocialAuthExceptionMiddleware',
 u'weblate.accounts.middleware.RequireLoginMiddleware',
 u'weblate.middleware.SecurityMiddleware']


Template error:
In template /usr/local/lib/python2.7/dist-packages/weblate/templates/glossary-embed.html, error at line 8
   invalid regular expression: regular expression is too complex
   1 : {% load i18n %}
   2 : {% load permissions %}
   3 : {% load translations %}
   4 : 
   5 : {% can_translate user unit as user_can_translate %}
   6 : {% can_suggest user unit.translation as user_can_suggest %}
   7 : 
   8 :  {% for item in glossary %} 
   9 :     <tr>
   10 :     <td>{{ item.source }}</td>
   11 :     <td class="target">{% format_translation item.target unit.translation.language simple=True %}</td>
   12 :     <td>
   13 :     {% if user_can_translate or user_can_suggest %}
   14 :     <a class="copydict btn btn-default btn-xs" title="{% trans "Copy word to translation" %}">{% trans "Copy" %}</a>
   15 :     {% endif %}
   16 :     </td>
   17 :     </tr>
   18 : {% empty %}


Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in inner
  185.                     return func(*args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/weblate/trans/views/edit.py" in translate
  599.             'addword_form': InlineWordForm(),

File "/usr/local/lib/python2.7/dist-packages/weblate/trans/util.py" in render
  208.     return django_render(request, template, context, status=status)

File "/usr/local/lib/python2.7/dist-packages/django/shortcuts.py" in render
  30.     content = loader.render_to_string(template_name, context, request, using=using)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
  68.     return template.render(context, request)

File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  207.                     return self._render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
  72.                 result = block.nodelist.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
  529.             return self.nodelist.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
  216.                 return template.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  209.                 return self._render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
  173.             len_values = len(values)

File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in __len__
  232.         self._fetch_all()

File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fetch_all
  1118.             self._result_cache = list(self._iterable_class(self))

File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in __iter__
  53.         results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)

File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
  899.             raise original_exception

Exception Type: DataError at /translate/test/test-es/es/
Exception Value: invalid regular expression: regular expression is too complex

Actual behaviour

The page fails with a 500 error.

Expected behaviour

The page should display the current translations.

Server configuration

  • Weblate 2.18
  • Python 2.7.13
  • Django 1.11.8
  • six 1.10.0
  • social-auth-core 1.5.0
  • social-auth-app-django 2.0.0
  • django-appconf 1.0.2
  • Translate Toolkit 2.2.5
  • Whoosh 2.7.4
  • defusedxml 0.5.0
  • Git 2.11.0
  • Pillow (PIL) 1.1.7
  • dateutil 2.5.3
  • lxml 3.7.1
  • django-crispy-forms 1.7.0
  • compressor 2.2
  • djangorestframework 3.7.3
  • pytz 2017.3
  • pyuca N/A
  • pyLibravatar N/A
  • PyYAML 3.12
  • tesserocr 2.2.2
  • Mercurial 4.0
  • git-svn 2.11.0
  • Database backends: django.db.backends.postgresql_psycopg2
bug

Most helpful comment

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see problem with the fix, please comment on this issue.
  • In case you see similar problem, please open separate issue.
  • If you are happy with the outcome, consider supporting Weblate by donating.

All 2 comments

Apparently we need something more clever for finding matched words in the glossary, current brute force approach doesn't scale well:

https://github.com/WeblateOrg/weblate/blob/4e3b780eea88f9f3f265e5447a220227a4430a2e/weblate/trans/models/dictionary.py#L120-L185

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see problem with the fix, please comment on this issue.
  • In case you see similar problem, please open separate issue.
  • If you are happy with the outcome, consider supporting Weblate by donating.
Was this page helpful?
0 / 5 - 0 ratings