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

Shlink.ERROR - ValueError: mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "windows-1255" #2334

Closed
leon2589 opened this issue Jan 12, 2025 · 1 comment · Fixed by #2343
Labels
Milestone

Comments

@leon2589
Copy link

leon2589 commented Jan 12, 2025

Shlink version

4.3.1

PHP version

8.3.15

How do you serve Shlink

Self-hosted Apache

Database engine

MySQL

Database version

8.0.40

Current behavior

Image

LOG:

Shlink.ERROR - ValueError: mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "windows-1255" in /var/www/example.com/module/Core/src/ShortUrl/Helper/ShortUrlTitleResolutionHelper.php:102
Stack trace:
//0 /var/www/example.com/module/Core/src/ShortUrl/Helper/ShortUrlTitleResolutionHelper.php(102): mb_convert_encoding()
//1 /var/www/example.com/module/Core/src/ShortUrl/Helper/ShortUrlTitleResolutionHelper.php(60): Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlTitleResolutionHelper->tryToResolveTitle()
//2 /var/www/example.com/module/Core/src/ShortUrl/UrlShortener.php(43): Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlTitleResolutionHelper->processTitle()
//3 /var/www/example.com/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php(29): Shlinkio\Shlink\Core\ShortUrl\UrlShortener->shorten()
//4 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Middleware/RequestHandlerMiddleware.php(46): Shlinkio\Shlink\Rest\Action\ShortUrl\AbstractCreateShortUrlAction->handle()
//5 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Laminas\Stratigility\Middleware\RequestHandlerMiddleware->process()
//6 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//7 /var/www/example.com/module/Rest/src/Middleware/ShortUrl/DefaultShortCodesLengthMiddleware.php(28): Laminas\Stratigility\Next->handle()
//8 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Rest\Middleware\ShortUrl\DefaultShortCodesLengthMiddleware->process()
//9 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//10 /var/www/example.com/module/Rest/src/Middleware/ShortUrl/OverrideDomainMiddleware.php(27): Laminas\Stratigility\Next->handle()
//11 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Rest\Middleware\ShortUrl\OverrideDomainMiddleware->process()
//12 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//13 /var/www/example.com/module/Rest/src/Middleware/ShortUrl/DropDefaultDomainFromRequestMiddleware.php(26): Laminas\Stratigility\Next->handle()
//14 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Rest\Middleware\ShortUrl\DropDefaultDomainFromRequestMiddleware->process()
//15 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//16 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//17 /var/www/example.com/vendor/mezzio/mezzio-router/src/Route.php(79): Laminas\Stratigility\MiddlewarePipe->process()
//18 /var/www/example.com/vendor/mezzio/mezzio-router/src/RouteResult.php(109): Mezzio\Router\Route->process()
//19 /var/www/example.com/vendor/mezzio/mezzio-router/src/Middleware/DispatchMiddleware.php(32): Mezzio\Router\RouteResult->process()
//20 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\Router\Middleware\DispatchMiddleware->process()
//21 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//22 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//23 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Laminas\Stratigility\MiddlewarePipe->process()
//24 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(122): Laminas\Stratigility\Next->handle()
//25 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(45): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
//26 /var/www/example.com/module/Rest/src/Middleware/AuthenticationMiddleware.php(52): Laminas\Stratigility\Next->handle()
//27 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Rest\Middleware\AuthenticationMiddleware->process()
//28 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//29 /var/www/example.com/module/Rest/src/Middleware/BodyParserMiddleware.php(37): Laminas\Stratigility\Next->handle()
//30 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware->process()
//31 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//32 /var/www/example.com/vendor/mezzio/mezzio-router/src/Middleware/ImplicitOptionsMiddleware.php(75): Laminas\Stratigility\Next->handle()
//33 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\Router\Middleware\ImplicitOptionsMiddleware->process()
//34 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//35 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//36 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(60): Laminas\Stratigility\MiddlewarePipe->process()
//37 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Laminas\Stratigility\Middleware\PathMiddlewareDecorator->process()
//38 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(45): Laminas\Stratigility\Next->handle()
//39 /var/www/example.com/vendor/mezzio/mezzio-router/src/Middleware/ImplicitHeadMiddleware.php(77): Laminas\Stratigility\Next->handle()
//40 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\Router\Middleware\ImplicitHeadMiddleware->process()
//41 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//42 /var/www/example.com/vendor/mezzio/mezzio-router/src/Middleware/RouteMiddleware.php(50): Laminas\Stratigility\Next->handle()
//43 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\Router\Middleware\RouteMiddleware->process()
//44 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//45 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//46 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Laminas\Stratigility\MiddlewarePipe->process()
//47 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(45): Laminas\Stratigility\Next->handle()
//48 /var/www/example.com/vendor/shlinkio/shlink-common/src/Middleware/CloseDbConnectionMiddleware.php(24): Laminas\Stratigility\Next->handle()
//49 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\CloseDbConnectionMiddleware->process()
//50 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//51 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//52 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Laminas\Stratigility\MiddlewarePipe->process()
//53 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(122): Laminas\Stratigility\Next->handle()
//54 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(45): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
//55 /var/www/example.com/vendor/mezzio/mezzio-problem-details/src/ProblemDetailsMiddleware.php(46): Laminas\Stratigility\Next->handle()
//56 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Mezzio\ProblemDetails\ProblemDetailsMiddleware->process()
//57 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//58 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//59 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php(60): Laminas\Stratigility\MiddlewarePipe->process()
//60 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Laminas\Stratigility\Middleware\PathMiddlewareDecorator->process()
//61 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(45): Laminas\Stratigility\Next->handle()
//62 /var/www/example.com/module/Rest/src/Middleware/CrossDomainMiddleware.php(24): Laminas\Stratigility\Next->handle()
//63 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware->process()
//64 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//65 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Middleware/ErrorHandler.php(129): Laminas\Stratigility\Next->handle()
//66 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Laminas\Stratigility\Middleware\ErrorHandler->process()
//67 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//68 /var/www/example.com/vendor/shlinkio/shlink-common/src/Middleware/RequestIdMiddleware.php(33): Laminas\Stratigility\Next->handle()
//69 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\RequestIdMiddleware->process()
//70 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//71 /var/www/example.com/vendor/shlinkio/shlink-common/src/Middleware/ContentLengthMiddleware.php(16): Laminas\Stratigility\Next->handle()
//72 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\ContentLengthMiddleware->process()
//73 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//74 /var/www/example.com/vendor/shlinkio/shlink-common/src/Middleware/AccessLogMiddleware.php(26): Laminas\Stratigility\Next->handle()
//75 /var/www/example.com/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php(26): Shlinkio\Shlink\Common\Middleware\AccessLogMiddleware->process()
//76 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Mezzio\Middleware\LazyLoadingMiddleware->process()
//77 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//78 /var/www/example.com/vendor/laminas/laminas-stratigility/src/Next.php(52): Laminas\Stratigility\MiddlewarePipe->process()
//79 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
//80 /var/www/example.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(66): Laminas\Stratigility\MiddlewarePipe->process()
//81 /var/www/example.com/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(73): Laminas\Stratigility\MiddlewarePipe->handle()
//82 /var/www/example.com/vendor/mezzio/mezzio/src/Application.php(53): Laminas\HttpHandlerRunner\RequestHandlerRunner->run()
//83 /var/www/example.com/config/run.php(13): Mezzio\Application->run()
//84 /var/www/example.com/public/index.php(5): {closure}()
//85 {main}

Expected behavior

short link not created

Minimum steps to reproduce

1 try to create short url for this url: https://www.tropicalfish.co.il/product/%D7%9E%D7%A2%D7%A8%D7%9B%D7%AA-uv-%D7%94%D7%97%D7%9C%D7%A4%D7%94-cpf10000-%D7%A1%D7%90%D7%9F-%D7%A1%D7%90%D7%9F-sunsun
2 you will get the error: "An unknown error occurred."

@acelaya
Copy link
Member

acelaya commented Jan 13, 2025

It looks the encoding used by this page is not supported by the function used to convert to UTF-8. I can confirm it by checking https://www.php.net/manual/en/mbstring.supported-encodings.php, where windows-1255 is not listed.

At the very least, this should cause the URL to be created without an auto-resolved title. On top of that, I can explore possible fallback alternatives to convert encodings, although I have tried with iconv, and while it supports windows-1255, it fails to convert from windows-1255 to UTF-8.

@acelaya acelaya added this to the 4.4.1 milestone Jan 13, 2025
@acelaya acelaya moved this to Todo in Shlink Jan 13, 2025
@acelaya acelaya moved this from Todo to In review in Shlink Jan 28, 2025
@github-project-automation github-project-automation bot moved this from In review to Done in Shlink Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants