f3-factory / fatfree-core

Fat-Free Framework core library
GNU General Public License v3.0
208 stars 88 forks source link

Route tokens containing slashes #216

Open xfra35 opened 7 years ago

xfra35 commented 7 years ago

This is a followup of #214.

When defining a route like GET /explorer/@path: should encoded slashes be allowed inside @path or not?

E.g: /explorer/abc%2fdef.

Background:

We need to decide:

Here are two suggestions for decoding UTF-8 characters while preserving encoded slashes:

// solution #1 (case sensitive)
$req=urldecode(str_replace(['%2f','%2F'],['%252f','%252F'],$this->hive['PATH']));

// solution #2 (case insensitive)
$req=implode('/',array_map(function($str){return str_replace('/','%2f',urldecode($str));},explode('/',$this->hive['PATH'])));
bcosca commented 7 years ago

Why not a configurable hive variable (like PASSTHRU) so we can maintain backward comptibility and at the same time allow the dev to make that decision to override default behavior?