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

API Tag contastaint #976

Closed
tobybatch opened this issue Jul 22, 2019 · 6 comments
Closed

API Tag contastaint #976

tobybatch opened this issue Jul 22, 2019 · 6 comments
Labels
Milestone

Comments

@tobybatch
Copy link
Member

tobybatch commented Jul 22, 2019

Describe the bug
Searching for issues filtered by tag using the API fails. The parameter a-b-issue-123 fails to pass the reg exp '[a-zA-Z0-9 -,]+'. I can't figure out why.

To Reproduce
Steps to reproduce the behavior:

  1. Install kimai, res-dev to populate data
  2. Log in to the web ui
  3. Execute the a search in the console:
$.ajax({
    url: "http://localhost:8001/api/timesheets?tags=a-b-issues-123",
    type: 'GET',
    beforeSend: function (request) {
        request.setRequestHeader("X-AUTH-SESSION", "THING-1");
    },
    headers: {
        'X-AUTH-SESSION': "THING-1",
    },
    success: console.log,
    error: console.log,
});
  1. We get a bad request (400)

Logfile

[2019-07-22 08:24:42] request.ERROR: Uncaught PHP Exception FOS\RestBundle\Exception\InvalidParameterException: "Parameter "tags" of value "a-b-issues-123" violated a constraint "Parameter 'tags' value, does not match requirements '[a-zA-Z0-9 -,]+'"" at /opt/kimai/vendor/friendsofsymfony/rest-bundle/Exception/InvalidParameterException.php line 68 {"exception":"[object] (FOS\\RestBundle\\Exception\\InvalidParameterException(code: 0): Parameter \"tags\" of value \"a-b-issues-123\" violated a constraint \"Parameter 'tags' value, does not match requirements '[a-zA-Z0-9 -,]+'\" at /opt/kimai/vendor/friendsofsymfony/rest-bundle/Exception/InvalidParameterException.php:68)"} []

Desktop/Smartphone
Please complete the following information if this seems to be a frontend issue:

  • Desktop
  • Ubuntu 19.04
  • Chrome/Firefox (tested both)
  • Version 75.0.3770.100 (Official Build) (64-bit)

Additional context
Add any other context about the problem here.

  • Master build (as of Friday 19/07/19)
  • PHP 7.3.6 (cli) (built: Jul 3 2019 20:52:08) ( NTS )

I'm running in a docker (of course). You can replicate the whole stack with this:

version: '3'
services:

  mydb:
    image: mysql:5.6
    environment:
      - MYSQL_DATABASE=kimai
      - MYSQL_USER=kimaiu
      - MYSQL_PASSWORD=kimaip
      - MYSQL_ROOT_PASSWORD=changeme
    volumes:
        - mysql:/var/lib/mysql
    command: --default-storage-engine innodb
    restart: always

  kimai:
    image: kimai/kimai2:apache-debian-master
    environment:
        - APP_ENV=dev
        - DATABASE_URL=mysql://kimaiu:kimaip@mydb/kimai
        - ADMINMAIL=kimai@example.com
        - ADMINPASS=pass123
    depends_on:
        - mydb
    ports:
        - 8001:8001
    restart: always

  postfix:
    image: catatnight/postfix
    environment:
      maildomain: neontribe.co.uk
      smtp_user: kimai:kimai
    restart: unless-stopped
    restart: always

volumes:
  mysql:
@kevinpapst
Copy link
Member

kevinpapst commented Jul 22, 2019

Can you try to replace the regexp in https://github.com/kevinpapst/kimai2/blob/master/src/API/TimesheetController.php#L111 from [a-zA-Z0-9 -,]+ to [a-zA-Z0-9 \-,]+, then clear the cache and retry?

Edit: I guess I forgot to escape the - character, which has special meaning in the regexp.

@tobybatch
Copy link
Member Author

Yes, that works. Do you want a PR or will you do it?

@kevinpapst
Copy link
Member

Both is okay, PR is even better :-)

@kevinpapst kevinpapst added the bug label Jul 22, 2019
@kevinpapst kevinpapst added this to the 1.1 milestone Jul 22, 2019
@tobybatch
Copy link
Member Author

I'll do you a PR. ;)

@kevinpapst
Copy link
Member

Fixed by #978

@lock
Copy link

lock bot commented Sep 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. If you use Kimai on a daily basis, please consider donating to support further development of Kimai.

@lock lock bot locked and limited conversation to collaborators Sep 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants