Added additional test case for UrlGenerator class#90
Added additional test case for UrlGenerator class#90LukeTowers merged 3 commits intowintercms:developfrom
Conversation
|
Added test cases fail so issue still exists (or I made super dummy mistake in these tests). wintercms/wn-translate-plugin#36 issue also mostly focus about this case because although initial filter URL is like |
|
I confirm. |
|
@arvislacis please add this to this PR, I think it fixes the issue: diff --git a/src/Router/UrlGenerator.php b/src/Router/UrlGenerator.php
index 5c6f4a8..7268b46 100644
--- a/src/Router/UrlGenerator.php
+++ b/src/Router/UrlGenerator.php
@@ -326,7 +326,7 @@ public static function buildStr(array $query, string $prefix = '', $argSeparator
if ($i === $k) {
if ($prefix) {
// Make sure the key is setup for array values
- if (Str::endsWith($prefix, '[]')) {
+ if (Str::endsWith($prefix, ']')) {
$key = $prefix;
} else {
$key = "{$prefix}[]"; |
|
@mjauvin Done in 5be073c As far as I tested then this solves my issue (wintercms/wn-translate-plugin#36) but I would suggest someone else also to take look. Also added another test case (f329c19) for storm/src/Router/UrlGenerator.php Line 341 in 32df10c ^ Everything is fine for this, I think test cases wouldn't be bad. Probably there could also be tests for storm/src/Router/UrlGenerator.php Line 332 in 32df10c storm/src/Router/UrlGenerator.php Line 336 in 32df10c |
|
@mjauvin A little bit off-topic but is there any particular reason Winter CMS has implemented it's own URL processing and decoding, encoding and not using the Laravel one? I understand that users are nasty and can insert a lot of interesting things in URLs so decoding/encoding and additional processing may avoid this. For example, if we look at my Locale Switcher case then for some users it also may look strange that |
|
@arvislacis it's because Laravel does not do any of the parsing or url encoding / decoding of URLs that Winter is doing. There is no guarantee in Laravel when you passing a value to I personally wanted a helper that would guarantee that the output generated by it was a spec-following URL that could be safely used in element attributes and anywhere else you might need a URL without worrying about potential injection attacks from users controlling part of or the entire URL. |
|
@LukeTowers Thanks for clarification. |
|
Thanks for the help @arvislacis & @mjauvin! |
* develop: Added additional test case for UrlGenerator class (#90) Improve port validation when building URLs
* develop: Apply fix from 1.0 Add test case for trimStringAttributes flag Make string attribute value auto-trimming optional (#97) Added additional test case for UrlGenerator class (#90) Improve port validation when building URLs Avoid issues coming from double encoded URLs remove non-existent argument to Ini::parse() method (#82) Fix docblock typehint (#71) Code quality and windows test fix Improve Halcyon SectionParser logic
I tested the latest 32df10c commit and it seems that issues described in wintercms/wn-translate-plugin#36 is not solved.
So I added additional test case.