| Message ID | 20260206075522.5620-1-liuyd.fnst@fujitsu.com |
|---|---|
| State | New |
| Headers | show |
| Series | [bitbake-devel,v2] bitbake-setup: Add strip to value from settings.conf | expand |
On Fri, 6 Feb 2026 at 08:55, Yiding Liu (Fujitsu) via lists.openembedded.org <liuyd.fnst=fujitsu.com@lists.openembedded.org> wrote: > + for section in settings.sections(): > + for key in settings[section]: > + value = settings[section][key] > + settings[section][key] = value.strip('"') I think this is okay, but should we strip both single ' and double " quotes? Sorry I didn't realize this earlier. Alex
> -----Original Message----- > From: bitbake-devel@lists.openembedded.org <bitbake-devel@lists.openembedded.org> On Behalf Of Alexander Kanavin via lists.openembedded.org > Sent: den 6 februari 2026 12:47 > To: liuyd.fnst@fujitsu.com > Cc: bitbake-devel@lists.openembedded.org > Subject: Re: [bitbake-devel][PATCH v2] bitbake-setup: Add strip to value from settings.conf > > On Fri, 6 Feb 2026 at 08:55, Yiding Liu (Fujitsu) via lists.openembedded.org <liuyd.fnst=fujitsu.com@lists.openembedded.org> wrote: > > + for section in settings.sections(): > > + for key in settings[section]: > > + value = settings[section][key] > > + settings[section][key] = value.strip('"') > > I think this is okay, but should we strip both single ' and double " > quotes? Sorry I didn't realize this earlier. > > Alex Maybe it would be better to abort if any odd characters are found in any of the settings? Because I assume the situation would be equally bad if someone somehow has ended up with a path like foo/"bar", i.e., with a quote in the middle. Aborting would allow bitbake-setup to give a meaningful error, rather than silently hiding the misconfiguration. //Peter
On Fri, 6 Feb 2026 at 13:50, Peter Kjellerstedt <peter.kjellerstedt@axis.com> wrote: > > > + for section in settings.sections(): > > > + for key in settings[section]: > > > + value = settings[section][key] > > > + settings[section][key] = value.strip('"') > > > > I think this is okay, but should we strip both single ' and double " > > quotes? Sorry I didn't realize this earlier. > Maybe it would be better to abort if any odd characters are found in any > of the settings? Because I assume the situation would be equally bad if > someone somehow has ended up with a path like foo/"bar", i.e., with a > quote in the middle. Aborting would allow bitbake-setup to give a > meaningful error, rather than silently hiding the misconfiguration. But on what condition would the abort happen? I'm not sure I can come up with a simple one. Now that you say it, I'm not sure how paths with spaces in them should be handled, as those do need to be quoted or do they? This can turn out into a rabbit hole :-/ Alex
> -----Original Message----- > From: Alexander Kanavin <alex.kanavin@gmail.com> > Sent: den 6 februari 2026 14:16 > To: Peter Kjellerstedt <peter.kjellerstedt@axis.com> > Cc: liuyd.fnst@fujitsu.com; bitbake-devel@lists.openembedded.org > Subject: Re: [bitbake-devel][PATCH v2] bitbake-setup: Add strip to value > from settings.conf > > On Fri, 6 Feb 2026 at 13:50, Peter Kjellerstedt <peter.kjellerstedt@axis.com> wrote: > > > > + for section in settings.sections(): > > > > + for key in settings[section]: > > > > + value = settings[section][key] > > > > + settings[section][key] = value.strip('"') > > > > > > I think this is okay, but should we strip both single ' and double " > > > quotes? Sorry I didn't realize this earlier. > > > > Maybe it would be better to abort if any odd characters are found in any > > of the settings? Because I assume the situation would be equally bad if > > someone somehow has ended up with a path like foo/"bar", i.e., with a > > quote in the middle. Aborting would allow bitbake-setup to give a > > meaningful error, rather than silently hiding the misconfiguration. > > But on what condition would the abort happen? I'm not sure I can come > up with a simple one. One way would be to start with a (small and) well defined set of characters that are supported. Then if someone has a use case that requires a character that is not supported, they would have to make a case for it, and the consequences of allowing that character too can be handled on a character by character basis. I do not know what are in those settings though, so it may be hard to define a set that works for all of them. > Now that you say it, I'm not sure how paths with spaces in them should > be handled, as those do need to be quoted or do they? This can turn > out into a rabbit hole :-/ > > Alex While handling paths with spaces is of course the right thing to do, I am not sure you actually need to handle that case since OE will fail badly if you try using such paths. But maybe bitbake (and thus bitbake-setup) does handle paths with spaces correctly? I have never thought about that... //Peter
diff --git a/bin/bitbake-setup b/bin/bitbake-setup index abe7614c8..e06c40dc6 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -869,6 +869,12 @@ def load_settings(settings_path): if os.path.exists(settings_path): logger.info('Loading settings from {}'.format(settings_path)) settings.read_file(open(settings_path)) + + for section in settings.sections(): + for key in settings[section]: + value = settings[section][key] + settings[section][key] = value.strip('"') + return settings def change_setting(top_dir, args):
If user add "" to dl-dir as DL_DIR, it will show FetchError as following. raise FetchError("Unable to fetch URL from any source.", u) bb.fetch2.FetchError: Fetcher failure for URL: 'git://git.openembedded.org/bitbake;protocol=https;rev=master;branch=master;destsuffix=bitbake'. Unable to fetch URL from any source. But from this log, user can't locate the real reason which is that the path "/aa/bb" is invalid. So I make this fix, even if user add "" to dl-dir, the dl-dir will be the valid path. Other settings value also need this fix. Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com> --- bin/bitbake-setup | 6 ++++++ 1 file changed, 6 insertions(+)