Bug: Using international characters breaks API querying
See original GitHub issueRelated to this #1591, same version, same error. It doesn’t work for Chinese characters
curl command
curl -X 'GET' \
'http://grocy.chenny.homes/api/objects/products?query%5B%5D=name~%E8%9E%BA%E4%B8%9D%20M2.5x30' \
-H 'accept: application/json'
In swagger:
Error:
{
"error_message": "Invalid query",
"error_details": {
"stack_trace": "#0 /app/grocy/controllers/BaseApiController.php(50): Grocy\\Controllers\\BaseApiController->filter()\n#1 /app/grocy/controllers/GenericEntityApiController.php(152): Grocy\\Controllers\\BaseApiController->queryData()\n#2 /app/grocy/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(43): Grocy\\Controllers\\GenericEntityApiController->GetObjects()\n#3 /app/grocy/vendor/slim/slim/Slim/Routing/Route.php(384): Slim\\Handlers\\Strategies\\RequestResponse->__invoke()\n#4 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\\Routing\\Route->handle()\n#5 /app/grocy/middleware/JsonMiddleware.php(13): Slim\\MiddlewareDispatcher->handle()\n#6 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(209): Grocy\\Middleware\\JsonMiddleware->__invoke()\n#7 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): class@anonymous->handle()\n#8 /app/grocy/vendor/slim/slim/Slim/Routing/Route.php(341): Slim\\MiddlewareDispatcher->handle()\n#9 /app/grocy/vendor/slim/slim/Slim/Routing/RouteRunner.php(84): Slim\\Routing\\Route->run()\n#10 /app/grocy/middleware/LocaleMiddleware.php(16): Slim\\Routing\\RouteRunner->handle()\n#11 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): Grocy\\Middleware\\LocaleMiddleware->__invoke()\n#12 /app/grocy/middleware/AuthMiddleware.php(76): class@anonymous->handle()\n#13 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): Grocy\\Middleware\\AuthMiddleware->__invoke()\n#14 /app/grocy/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(59): class@anonymous->handle()\n#15 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\\Middleware\\RoutingMiddleware->process()\n#16 /app/grocy/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(107): class@anonymous->handle()\n#17 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\\Middleware\\ErrorMiddleware->process()\n#18 /app/grocy/middleware/CorsMiddleware.php(30): class@anonymous->handle()\n#19 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): Grocy\\Middleware\\CorsMiddleware->__invoke()\n#20 /app/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): class@anonymous->handle()\n#21 /app/grocy/vendor/slim/slim/Slim/App.php(215): Slim\\MiddlewareDispatcher->handle()\n#22 /app/grocy/vendor/slim/slim/Slim/App.php(199): Slim\\App->handle()\n#23 /app/grocy/app.php(106): Slim\\App->run()\n#24 /app/grocy/public/index.php(45): require_once('/app/grocy/app....')\n#25 {main}",
"file": "/app/grocy/controllers/BaseApiController.php",
"line": 95
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
WebAPI does not properly encode special characters #641
While digging in my own toys, I've found out that current WebAPI code does not properly encode special characters.
Read more >Web.Contents function un-encoding '%2F' to a '/' when using ...
I'm trying to call a web API with Web.Contents, example power query:- let URL = "https://www.example.com/en-gb", Encode = Uri.
Read more >BUG: Characters are >Randomly< missing in the HTML ...
BUG : Characters are >Randomly< missing in the HTML Output of the Page. Hi! I've got a really strange Bug: I used to...
Read more >Escaping special character in simple and advanced search ...
Bug JRASERVER-25092 - Searching JIRA issues for special characters (in text fields) does not work, even if these characters have been properly escaped...
Read more >When are you supposed to use escape instead of encodeURI ...
Use encodeURIComponent when you want to encode the value of a URL parameter. ... Note that encodeURIComponent does not escape the ' character....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The default demo doesn’t have a product with id
30
and the public pre-release demo instance get also resetted 10 minutes past every hour as stated in README.So to be able to fully check and persistently reproduce that, I would first create a persistent demo instance - did that: => https://test-a8esm6e2e86rfpoq6v41x.demo-prerelease.grocy.info => Your product
螺母 nut M3
(has id27
there): https://test-a8esm6e2e86rfpoq6v41x.demo-prerelease.grocy.info/product/27==> Cannot be found via name
equals
: /objects/products?query[]=name=%E8%9E%BA%E6%AF%8D%20nut%20M3 ==> Can be found via nameLIKE
: /objects/products?query[]=name~螺母 ==> Can be found via id: /objects/products?query[]=name~螺母So turns out this is a completely other problem:
query[]
values seem to be split by (the first) space, so only螺母
is used when you provide螺母 nut M3
. Despite using international characters or not. => Will be tracked in #1624.And just for reference: The
query[]
parameters are directly translated to corresponding SQL WHERE clause(s) here. So if something doesn’t match, another check would be also to query the data manually first to verifiy it’s found via that way.I plan nothing about grocy, also that is mentioned in README.
Since everything is done in public, you can simply apply the patch for #1591 manually to have it now.
https://github.com/grocy/grocy/commit/14bb04d285a3c04508f4ba8b837a1de805fd2c34.patch
https://github.com/grocy/grocy/commit/14bb04d285a3c04508f4ba8b837a1de805fd2c34