Bug Report and Proposed Solution: Syntax Error with Special Characters in URL Handling
-
I hope you're doing well. I would like to report a bug related to URL handling in Bagisto and propose a potential solution that I've implemented.
When a URL or search query contains special characters, specifically an apostrophe ('), it triggers a syntax error in the Vue component, causing the following error message:
Uncaught SyntaxError: missing ) after argument list
To reproduce the issue, navigate to the search page and enter a query containing an apostrophe, such as Men's Shoes. The following error appears in the console:Uncaught SyntaxError: missing ) after argument list
The expected behavior is for the search page to handle special characters, including apostrophes, correctly without breaking the page. However, the current behavior causes a syntax error, preventing the product listing from displaying properly.
To fix this, I implemented the following solution in the Blade template to escape the title using the addslashes function. This ensures that special characters are handled correctly in the search query:
<h1 class="text-2xl font-medium max-sm:text-base" v-text="
{{ addslashes($title) }}
" style="margin-top: 5%;"></h1>
This change can be made in the file located at packages/Webkul/Shop/src/Resources/views/search/index.blade.php.After making this adjustment, the page now correctly handles search queries with special characters without throwing errors, and products are displayed as expected.
-
Thank you for your concern and query. I am pleased to inform you that the issue has already been raised and is currently being addressed.
For your reference, you can track the progress here: https://github.com/bagisto/bagisto/issues/10217