Skip to content

Commit

Permalink
adding explicit check for ending slash on endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
padams committed Sep 11, 2022
1 parent 49c7595 commit a537f35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion owa-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,10 @@ public function registerOptions() {
'title' => 'OWA Endpoint',
'page_name' => 'owa-wordpress',
'section' => 'general',
'description' => 'The URL of your OWA instance (i.e. http://www.mydomain.com/path/to/owa/). This should be the same as the OWA_PUBLIC_URL of your OWA server instance as defined in its owa-config.php file.',
'description' => 'The URL of your OWA instance (i.e. http://www.mydomain.com/path/to/owa/). This should be the same as the OWA_PUBLIC_URL of your OWA server instance as defined in its owa-config.php file and MUST end with a "/".',
'label_for' => 'OWA Endpoint',
'length' => 70,
'endWithSlash' => true,
'error_message' => ''
)
),
Expand Down
15 changes: 15 additions & 0 deletions src/settings/fields/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ public function isValid( $value ) {

return false;
}

// check to ensure the URL ends with a slash.

if ( $this->get( 'endWithSlash' ) && substr( $value, -1, 1 ) != "/" ) {

$this->addError(
$this->get('dom_id'),
sprintf(
'%s %s',
$this->get( 'label_for' ),
\owaWp\util::localize( 'URL must end with a slash. (i.e. http://mydomain.com/owa/ )' ) ) );

return false;
}


if ( filter_var( $value, FILTER_VALIDATE_URL ) ) {

Expand Down

0 comments on commit a537f35

Please sign in to comment.