jimmyl0l3c / cfg_share_links

App for Nextcloud that adds the ability to specify share tokens
GNU Affero General Public License v3.0
32 stars 3 forks source link

Error when creating a link longer than 32 characters #116

Closed vc closed 1 month ago

vc commented 1 year ago

Configurable Share Links v3.0.2 Nextcloud Hub 3 v25.0.1

When I tried to create a link with a length of 34 characters, I got an error. An error in the user interface does not give any information about the reason for its occurrence. I think that if there is a limit on the length of the link, it is necessary to inform the user explicitly about this.

[index] Ошибка: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing a query: SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(32) at <<closure>>

 0. /var/www/html/3rdparty/doctrine/dbal/src/Connection.php line 1780
    Doctrine\DBAL\Driver\API\PostgreSQL\ExceptionConverter->convert(Doctrine\DBAL\Driver\PDO\Exception {}, Doctrine\DBAL\Query {})
 1. /var/www/html/3rdparty/doctrine/dbal/src/Connection.php line 1719
    Doctrine\DBAL\Connection->handleDriverException(Doctrine\DBAL\Driver\PDO\Exception {}, Doctrine\DBAL\Query {})
 2. /var/www/html/3rdparty/doctrine/dbal/src/Connection.php line 1173
    Doctrine\DBAL\Connection->convertExceptionDuringQuery(Doctrine\DBAL\Driver\PDO\Exception {}, "UPDATE \"oc_sha ... ?", [null,false,"E78 ... "], [2,5,2,2,2,"And  ... "])
 3. /var/www/html/lib/private/DB/Connection.php line 294
    Doctrine\DBAL\Connection->executeStatement("UPDATE \"oc_sha ... ?", [null,false,"E78 ... "], [2,5,2,2,2,"And  ... "])
 4. /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php line 354
    OC\DB\Connection->executeStatement("UPDATE \"oc_sha ... 1", ["45",null,false ... "], [2,2,5,2,2,"And  ... "])
 5. /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php line 281
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /var/www/html/lib/private/Share20/DefaultShareProvider.php line 336
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /var/www/html/lib/private/Share20/Manager.php line 1061
    OC\Share20\DefaultShareProvider->update("*** sensitive parameters replaced ***")
 8. /var/www/html/custom_apps/cfg_share_links/lib/Service/ShareService.php line 196
    OC\Share20\Manager->updateShare("*** sensitive parameters replaced ***")
 9. /var/www/html/custom_apps/cfg_share_links/lib/Controller/ShareController.php line 38
    OCA\CfgShareLinks\Service\ShareService->create("/op_marketing_p ... f", 3, "Company-and-services-OnlinePatent1", "E7893E89-59B3-47D1-BE63-618ACBDE30F4", "")
10. /var/www/html/custom_apps/cfg_share_links/lib/Controller/Errors.php line 40
    OCA\CfgShareLinks\Controller\ShareController->OCA\CfgShareLinks\Controller\{closure}("*** sensitive parameters replaced ***")
11. /var/www/html/custom_apps/cfg_share_links/lib/Controller/ShareController.php line 39
    OCA\CfgShareLinks\Controller\ShareController->handleException(Closure {})
12. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 225
    OCA\CfgShareLinks\Controller\ShareController->create("/op_marketing_p ... f", 3, "Company-and-services-OnlinePatent1", "")
13. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 133
    OC\AppFramework\Http\Dispatcher->executeController(OCA\CfgShareLink ... {}, "create")
14. /var/www/html/lib/private/AppFramework/App.php line 172
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\CfgShareLink ... {}, "create")
15. /var/www/html/lib/private/Route/Router.php line 298
    OC\AppFramework\App::main("OCA\\CfgShareLi ... r", "create", OC\AppFramework\ ... {}, ["cfg_share_links.share.create"])
16. /var/www/html/lib/base.php line 1047
    OC\Route\Router->match("/apps/cfg_share_links/new")
17. /var/www/html/index.php line 36
    OC::handleRequest()

POST /apps/cfg_share_links/new
from 192.168.52.137 by E7893E89-59B3-47D1-BE63-618ACBDE30F4 at 2023-03-01T10:03:10+00:00

Changing the link length to 24 characters fixed the situation and the link was created.

jimmyl0l3c commented 1 year ago

Hi, thank you for reporting this issue. I agree that it should at least show proper error message. Unfortunately I wont have time to look at it sooner then in May or June.

jimmyl0l3c commented 1 month ago

Hi, the root cause is that Nextcloud uses varchar(32) for its link tokens, so you cannot save links longer than that. Since v5.1.3 the app will check this upper limit and display a proper error message when trying to save longer links.