-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pods_clean_name cleanup #3012
Labels
Type: Enhancement
Enhancements to features that already exist, but are not major additions
Milestone
Comments
sc0ttkclark
added
the
Type: Enhancement
Enhancements to features that already exist, but are not major additions
label
Jun 8, 2015
/**
* Return a lowercase alphanumeric name (with underscores and dashes)
*
* @param string $orig Input string to clean
* @param boolean $lower Force lowercase
* @param boolean $trim_underscores Whether to trim off underscores
*
* @return string Sanitized name
*
* @since 1.2.0
*/
function pods_clean_name ( $orig, $lower = true, $trim_underscores = false ) {
$str = trim( $str );
$str = preg_replace( "/([^0-9a-zA-Z\-_])/", "", $str );
$str = preg_replace( "/(_){2,}/", "_", $str );
$str = preg_replace( "/(-){2,}/", "-", $str );
if ( $lower ) {
$str = strtolower( $str );
}
if ( $trim_underscores ) {
$str = trim( $str, '_' );
}
return $str;
}
/**
* Return a lowercase alphanumeric name (with underscores) for safe Javascript variable names
*
* @param string $orig Input string to clean
* @param boolean $lower Force lowercase
*
* @return string Sanitized name
*
* @since 2.5.4
*/
function pods_js_name( $orig, $lower = true ) {
$str = pods_clean_name( $orig, $lower );
$str = str_replace( '-', '_', $str );
return $str;
} |
Assigned to @quasel for PR on |
Added another task for traversal support |
guess |
Yep, sorry about that, coding via a GitHub comment lol |
Can you also make this change to https://github.com/pods-framework/pods/blob/master/ui/fields/_db.php var newval = $( this ).val().toLowerCase().replace( /([- ])/g, '_' ).replace( /([^0-9a-z_])/g, '' ).replace( /(_){2,}/g, '_' ).replace( /_$/, '' ); with: var newval = $( this ).val().toLowerCase().replace( /(\s)/g, '_' ).replace( /([^0-9a-z_\-])/g, '' ).replace( /(_){2,}/g, '_' ).replace( /_$/, '' ); |
This was referenced Sep 3, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pods_clean_name
usage and definition needs some tweaking.pods/includes/data.php
Line 1310 in 2446a2d
pods_clean_name
function with code in commentpods_js_name
functionpods_clean_name
should now usepods_js_name
(see: https://github.com/pods-framework/pods/search?q=pods_clean_name&utf8=%E2%9C%93)pods_clean_name
should usepods_js_name( $orig, false )
(see:pods/classes/PodsComponents.php
Line 410 in ad02de6
[\w]
matches in traversal code with[\w\-]
in https://github.com/pods-framework/pods/blob/master/classes/PodsData.php#L1201 and https://github.com/pods-framework/pods/blob/master/classes/PodsData.php#L2278The text was updated successfully, but these errors were encountered: