Bug 9611

Summary: Under Project->Bitbake variable, We disallow variables with a '/' in them
Product: [Build System, Metadata & Runtime] Toaster Reporter: brian avery <brian.avery>
Component: toasterAssignee: Belen Barros Pena <belen.barros.pena>
Status: RESOLVED FIXED QA Contact: Libertad <libertad.gonzalez.de.la.cruz>
Severity: normal    
Priority: Medium CC: belen.barros.pena, bluelightning, jessica.zhang, ross.burton, stanciux.mihail
Version: 2.0   
Target Milestone: 2.2 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description brian avery 2016-05-09 23:00:13 UTC
an example of such a variable that we might want to set is PREFERRED_PROVIDER_virtual/java2-runtime to openjdk-7-jre.
Our javascript checker says:
'A valid variable name can only include letters, numbers, underscores, and dashes'
Comment 1 Paul Eggleton 2016-05-12 03:59:18 UTC
+ is allowed and used in recipe names, so it needs to be allowed in variable names here too (since it can therefore appear in a valid _pn- override).
Comment 2 Belen Barros Pena 2016-05-12 14:34:04 UTC
so, it's / and + so far. Any other special character we ought to allow?
Comment 3 brian avery 2016-05-12 17:30:48 UTC
What about not restricting the inputs?  If they put in an unparseable variable, the error message should be clear, I would think.
Comment 4 Belen Barros Pena 2016-05-13 09:38:54 UTC
(In reply to comment #3)
> What about not restricting the inputs?  If they put in an unparseable
> variable, the error message should be clear, I would think.

mmm, personally I don't like the approach. The CLI already let's you shoot yourself in the foot: we don't need the GUI to do that too. Most special characters are probably not allowed in OE variables (or so I was told when I designed that page). If that's the case, let's validate user input, as good web forms should.

Turns out there is an answer to this in BitBake

http://git.openembedded.org/bitbake/tree/lib/bb/parse/parse_py/ConfHandler.py#n33

According to RP, (?P<var>[a-zA-Z0-9\-~_+.${}/]+?) is the key bit. It implies 

a-zA-Z0-9\-~_+.${}/ 

are all acceptable 

So here is our answer: those are the special characters the validation should allow.
Comment 5 brian avery 2016-05-13 21:23:46 UTC
Agreed. Your's is better.
Comment 6 Belen Barros Pena 2016-09-05 11:06:11 UTC
Patch submitted to the mailing list

https://lists.yoctoproject.org/pipermail/toaster/2016-September/005164.html
Comment 7 Ross Burton 2016-09-19 12:49:14 UTC
Merged in bitbake 146f6f95a8753308edb31e952d7c440c8de11870.