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

Regex flag have an unexpected behavior #4482

Closed
Heziode opened this issue Sep 10, 2020 · 4 comments
Closed

Regex flag have an unexpected behavior #4482

Heziode opened this issue Sep 10, 2020 · 4 comments

Comments

@Heziode
Copy link

Heziode commented Sep 10, 2020

Describe the bug

Regex flag do not capture the last character when it is a closing parenthesis.
Regex flag do not capture well pattern inside { and }.

To Reproduce

Steps to reproduce the behavior:

I add this regex flag: regex:"((?:@:\(|\{)[^\)\}]+(?:\)|\}))"
Testing string: @:(foo.bar.baz) | @:(hello.world) | {foo32}
Check on regex101: https://regex101.com/r/SZVYGO/1

Expected behavior

Regex flag do capture the last character when it is a closing parenthesis.
Regex flag do capture well pattern inside { and }.

Screenshots

2020-09-10 13 17 16 translate foe tools 036dda149824

Server configuration and status

docker-compose exec weblate weblate list_versions:

  • Weblate: 4.1.1
  • Django: 3.0.7
  • siphashc: 1.3
  • Whoosh: 2.7.4
  • translate-toolkit: 3.0.0
  • lxml: 4.5.1
  • Pillow: 7.1.2
  • bleach: 3.1.5
  • python-dateutil: 2.8.1
  • social-auth-core: 3.3.3
  • social-auth-app-django: 3.4.0
  • django-crispy-forms: 1.9.1
  • oauthlib: 3.1.0
  • django-compressor: 2.4
  • djangorestframework: 3.11.0
  • django-filter: 2.3.0
  • django-appconf: 1.0.4
  • user-agents: 2.1
  • filelock: 3.0.12
  • setuptools: 40.8.0
  • jellyfish: 0.8.2
  • openpyxl: 3.0.1
  • celery: 4.4.5
  • kombu: 4.6.10
  • translation-finder: 2.1
  • html2text: 2020.1.16
  • pycairo: 1.16.2
  • pygobject: 3.30.4
  • diff-match-patch: 20181111
  • requests: 2.24.0
  • django-redis: 4.12.1
  • hiredis: 1.0.1
  • sentry_sdk: 0.15.1
  • Cython: 0.29.20
  • misaka: 2.1.1
  • GitPython: 3.1.3
  • borgbackup: 1.1.13
  • pyparsing: 2.4.7
  • Python: 3.7.3
  • Git: 2.20.1
  • psycopg2: 2.8.5
  • psycopg2-binary: 2.8.5
  • phply: 1.2.5
  • chardet: 3.0.4
  • ruamel.yaml: 0.16.10
  • tesserocr: 2.5.1
  • akismet: 1.1
  • boto3: 1.14.6
  • zeep: 3.4.0
  • aeidon: 1.7.0
  • iniparse: 0.5
  • mysqlclient: 1.4.6
  • Mercurial: 5.4.1
  • git-svn: 2.20.1
  • git-review: 1.28.0
  • hub: 2.13.0
  • lab: 0.16
  • Redis server: 4.0.14
  • PostgreSQL server: 11.8
  • Database backends: django.db.backends.postgresql
  • Cache backends: default:RedisCache, avatar:FileBasedCache
  • Email setup: django.core.mail.backends.smtp.EmailBackend: mailu_front
  • OS encoding: filesystem=utf-8, default=utf-8
  • Celery: redis://cache:6379/1, redis://cache:6379/1, regular
  • Platform: Linux 4.19.128-xxxx-std-ipv6-64 (x86_64)

Weblate deploy checks

docker-compose exec --user weblate weblate weblate check --deploy:

SystemCheckError: System check identified some issues:

CRITICALS:
?: (weblate.E003) Cannot send e-mail ([Errno -2] Name or service not known), please check EMAIL_* settings.
	HINT: https://docs.weblate.org/en/weblate-4.1.1/admin/install.html#out-mail

WARNINGS:
?: (security.W005) You have not set the SECURE_HSTS_INCLUDE_SUBDOMAINS setting to True. Without this, your site is potentially vulnerable to attack via an insecure connection to a subdomain. Only set this to True if you are certain that all subdomains of your domain should be served exclusively via SSL.

INFOS:
?: (weblate.I021) Error collection is not set up, it is highly recommended for production use
	HINT: https://docs.weblate.org/en/weblate-4.1.1/admin/install.html#collecting-errors
?: (weblate.I028) Backups are not configured, it is highly recommended for production use
	HINT: https://docs.weblate.org/en/weblate-4.1.1/admin/backup.html
?: (weblate.I031) New Weblate version is available, please upgrade to 4.2.2.
	HINT: https://docs.weblate.org/en/weblate-4.1.1/admin/upgrade.html

System check identified 5 issues (1 silenced).
nijel added a commit that referenced this issue Sep 10, 2020
The remaining question is whether this is expected behavior or not...

Issue #4482
@nijel
Copy link
Member

nijel commented Sep 10, 2020

The problem here is that flag parsing handles escape sequences as well, so your expression is parsed as: ((?:@:(|{)[^)}]+(?:)|}))

This matches exactly what you observe: https://regex101.com/r/O9zVx5/1

Such behavior is probably not desired, I will look whether it's possible to address this (especially whether something else relies in this behavior).

@Heziode
Copy link
Author

Heziode commented Sep 10, 2020

The problem here is that flag parsing handles escape sequences as well, so your expression is parsed as: ((?:@:(|{)[^)}]+(?:)|}))

Exact !

Furthermore, it's planed to add regex support for placeholders ?

@nijel
Copy link
Member

nijel commented Sep 10, 2020

Furthermore, it's planed to add regex support for placeholders ?

No, feel free to create separate issue for that.

@nijel nijel closed this as completed in 1762989 Sep 10, 2020
@github-actions
Copy link

The issue you have reported seems to be resolved now.

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

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

No branches or pull requests

2 participants