Escape double quotes when migrating portal settings. #1814
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a bug in which double quotes are not properly escaped when migrating portal settings.
Motivation and Context
This was noticed when testing the upgrade path for the
ondemand
module.In
xdmod-ondemand
, inconfiguration/portal_settings.d/ondemand.ini
, the value forwebserver_format_str
has backslash-escaped double quotes.When running the test steps below (which are based on the CircleCI upgrade path for
xdmod-ondemand
) (and instead cloninghttps://github.com/ubccr/xdmod
into/xdmod
), after running the first set of commands, the file/etc/xdmod/portal_settings.d/ondemand.ini
had unescaped quotes.This is because when the file is parsed in
classes/OpenXdmod/Migration/ConfigFilesMigration.php
in the functionwriteModulePortalSettingsFile
when it callsparse_ini_file
, the backslashes are not preserved in the data, so they are not written back into the file.Then, after running the second set of commands below, the web server log parser prints
Skip
for each of the lines in the example log file, so no data are loaded into themodw_ondemand
database, because the double quotes in the format string are not being properly escaped in the regex used to parse the file.Tests performed
In a Docker container running
tools-ext-01.ccr.xdmod.org/xdmod-10.5.0-x86_64:rockylinux8.5-0.3
:webserver_format_str
is the same for/etc/xdmod/portal_settings.d/ondemand.ini
and/xdmod/open_xdmod/modules/ondemand/configuration/portal_settings.d/ondemand.ini
.xdmod-ondemand
intests/scripts/bootstrap.sh
):Skip
for the lines in the example log file, and themodw_ondemand
database has the expected data.Checklist: