From b4bba8ae8ac4b3a72f84d16a1859823bebfbc2a8 Mon Sep 17 00:00:00 2001 From: JpMaxMan Date: Sat, 5 Sep 2026 17:48:21 -0500 Subject: [PATCH] Fix doubled base URL in survey step navigation Pressing "Go Back" on a survey step could navigate to a URL with the site origin repeated, for example: https://www.openstack.org + https://www.openstack.org/user-survey/... which the browser then resolves as a path, and the request fails. getPreviousStepUrl() built its URL as: Controller::join_links( Director::absoluteBaseURL(), Controller::curr()->Link(), ... ) Controller::join_links() concatenates its arguments and does not detect that a later argument is already an absolute URL, so this is only correct while Link() returns a relative path. Link() is built on Director::baseURL(), which returns Director.alternate_base_url when one is configured -- as SS_BASE_URL does. Setting SS_BASE_URL to a full origin, which is reasonable when the site sits behind a reverse proxy, makes Link() absolute and the origin is then emitted twice. Use Director::absoluteURL() around the joined relative path instead. It returns a URL unchanged when it already begins with http and prepends the base otherwise, so the result is correct whether Link() is relative or absolute, and stays correct if that configuration changes again. Applied to all four call sites that prepended the base by hand: the three getPreviousStepUrl() implementations behind the "Go Back" button, and the server-side redirect in SurveyPage when a requested step is not allowed. EntitySurveyTeamMemberEmailSenderService also calls absoluteBaseURL(), but composes it with Director::makeRelative(), which strips any base first. It is unaffected and left unchanged. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Uz3HpgshDPXb5GL7cdYZJh --- survey_builder/code/ui/frontend/SurveyPage.php | 5 ++--- .../builders/EntitySurveyRegularStepTemplateUIBuilder.php | 5 ++--- .../builders/SurveyAbstractStepTemplateUIBuilder.php | 5 ++--- .../frontend/builders/SurveyReviewStepTemplateUIBuilder.php | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/survey_builder/code/ui/frontend/SurveyPage.php b/survey_builder/code/ui/frontend/SurveyPage.php index 7cfe1bd466..32b094c1b8 100644 --- a/survey_builder/code/ui/frontend/SurveyPage.php +++ b/survey_builder/code/ui/frontend/SurveyPage.php @@ -703,15 +703,14 @@ public function EditEntity($request) { // if we are not allowed to go to desired step , redirect to current step - $current_url = Controller::join_links + $current_url = Director::absoluteURL(Controller::join_links ( - Director::absoluteBaseURL(), $this->Link(), $step, 'edit', $entity_survey_id, $entity_step_template->title() - ); + )); return $this->redirect($current_url); } diff --git a/survey_builder/code/ui/frontend/builders/EntitySurveyRegularStepTemplateUIBuilder.php b/survey_builder/code/ui/frontend/builders/EntitySurveyRegularStepTemplateUIBuilder.php index d741c64415..17f6d3fb2d 100644 --- a/survey_builder/code/ui/frontend/builders/EntitySurveyRegularStepTemplateUIBuilder.php +++ b/survey_builder/code/ui/frontend/builders/EntitySurveyRegularStepTemplateUIBuilder.php @@ -71,15 +71,14 @@ protected function getPreviousStepUrl(ISurveyStep $previous_step) throw new LogicException('step empty! - member_id %s', Member::currentUserID()); $entity_survey_id = intval($request->param('ENTITY_SURVEY_ID')); - $prev_step_url = Controller::join_links + $prev_step_url = Director::absoluteURL(Controller::join_links ( - Director::absoluteBaseURL(), Controller::curr()->Link(), $step, 'edit', $entity_survey_id, $previous_step->template()->title() - ); + )); return $prev_step_url; } } \ No newline at end of file diff --git a/survey_builder/code/ui/frontend/builders/SurveyAbstractStepTemplateUIBuilder.php b/survey_builder/code/ui/frontend/builders/SurveyAbstractStepTemplateUIBuilder.php index 5163815b87..789ee7ac4c 100644 --- a/survey_builder/code/ui/frontend/builders/SurveyAbstractStepTemplateUIBuilder.php +++ b/survey_builder/code/ui/frontend/builders/SurveyAbstractStepTemplateUIBuilder.php @@ -38,12 +38,11 @@ public function setNextButtonTitle($next_btn_title){ * @return String */ protected function getPreviousStepUrl(ISurveyStep $previous_step){ - $prev_step_url = Controller::join_links + $prev_step_url = Director::absoluteURL(Controller::join_links ( - Director::absoluteBaseURL(), Controller::curr()->Link(), $previous_step->template()->title() - ); + )); return $prev_step_url; } diff --git a/survey_builder/code/ui/frontend/builders/SurveyReviewStepTemplateUIBuilder.php b/survey_builder/code/ui/frontend/builders/SurveyReviewStepTemplateUIBuilder.php index d8c62801d2..beab722da6 100644 --- a/survey_builder/code/ui/frontend/builders/SurveyReviewStepTemplateUIBuilder.php +++ b/survey_builder/code/ui/frontend/builders/SurveyReviewStepTemplateUIBuilder.php @@ -48,12 +48,11 @@ public function build(ISurveyStep $step, $action, $form_name = 'SurveyStepForm') * @return String */ protected function getPreviousStepUrl(ISurveyStep $previous_step){ - $prev_step_url = Controller::join_links + $prev_step_url = Director::absoluteURL(Controller::join_links ( - Director::absoluteBaseURL(), Controller::curr()->Link(), $previous_step->template()->title() - ); + )); return $prev_step_url; }