function _acquia_purge_input_clean in Acquia Purge 7
Perform necessary string cleaning on a provided path string.
Whenever working with user input it is required to first validate with _acquia_purge_input_validate() before cleaning it.
Parameters
string $path: The Drupal path (for example: '<front>', 'user/1' or a alias).
Return value
string The cleaned version of the path.
4 calls to _acquia_purge_input_clean()
- AcquiaPurgeService::addPath in lib/
AcquiaPurgeService.php - Queue a single path.
- AcquiaPurgeService::addPaths in lib/
AcquiaPurgeService.php - Queue several paths.
- _acquia_purge_action_flush_url in ./
acquia_purge.rules.inc - Purge URL(s) and Path(s), directly using Acquia Purge's APIs.
- _acquia_purge_input_path_variations in ./
acquia_purge.module - Make up variations on the given paths for lazier administrative cleaning.
File
- ./
acquia_purge.module, line 426 - Acquia Purge, Top-notch Varnish purging on Acquia Cloud!
Code
function _acquia_purge_input_clean($path) {
if (!is_string($path)) {
return '';
}
$path = trim($path);
if (empty($path) || $path === '/') {
return '';
}
// Remove double slashes that might occur in strings.
$path = str_replace('//', '/', $path);
// Remove leading slashes as we add those in later too.
$path = ltrim($path, '/');
// Rewrite '<front>' to '', which will always be the frontpage. By using
// substr() and str_replace() we still allow cases like '<front>?param=1'.
if (drupal_substr($path, 0, 7) === '<front>') {
$path = str_replace('<front>', '', $path);
}
return $path;
}