String settings with special characters become quoted

Bug #1552082 reported by Brian Douglass
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
Medium
Alejandro J. Cura
unity-js-scopes
Invalid
Undecided
Unassigned
unity-api (Ubuntu)
Fix Released
Undecided
Marcus Tomlinson
unity-scopes-shell (Ubuntu)
Fix Released
Undecided
Marcus Tomlinson

Bug Description

I'm unsure if this is a bug in the JS scopes or in scopes themselves, but a string setting that has special characters entered into it (like `=`) end up being surrounded by quotes when pulled in the code. For example I have a string setting that I entered `abc=abc`, the result in the code is `"abc=abc"`. I find this behavior to be very odd and unexpected.

Related branches

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Hmm, I can't seem to reproduce this. I have the following setting:

    [location]
    type = string
    defaultValue = abc=abc
    _displayName = Default Location

Then in the code I'm doing:

    console.log("location : " + scopes.self.settings["location"].get_string());

And I see the output:

    location : abc=abc

No quotes.

Could you please describe your use case.

Changed in unity-js-scopes:
assignee: nobody → Marcus Tomlinson (marcustomlinson)
status: New → In Progress
Revision history for this message
Brian Douglass (bhdouglass) wrote :

With the default value set I don't see the quotes, but when I leave off the default and manually put a value in myself it has the quotes. If needed I can send you the example I just created.

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Ah, I see it now. Ok, looking into it.

Changed in unity-api (Ubuntu):
assignee: nobody → Marcus Tomlinson (marcustomlinson)
status: New → In Progress
Changed in unity-js-scopes:
status: In Progress → Invalid
Changed in unity-js-scopes:
status: Invalid → In Progress
no longer affects: unity-api (Ubuntu)
Changed in unity-scopes-shell (Ubuntu):
status: New → In Progress
assignee: nobody → Marcus Tomlinson (marcustomlinson)
Changed in unity-js-scopes:
status: In Progress → Invalid
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

I've tracked this issue down to a mismatch in string storage formatting between QSettings (used in unity-scopes-shell) and glib (used in unity-api).

After some discussion with the team, I think the best way forward would be to standardise on one ini parser across the board. I.e. update unity-scopes-shell to use glib via unity-api's IniParser interface.

This way, what goes in, will come out.

Revision history for this message
Brian Douglass (bhdouglass) wrote :

Perfect! Thank you for looking into this. Is there an ETA on when this could be released into the wild?

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

@Brian, unfortunately changes to unity-scopes-shell take considerably longer to land than changes to our bindings, so I can't promise it'll be available any sooner than 1, maybe 2 weeks.

My suggestion would be to implement a workaround in your JS code for the time being that checks for quotes either side of a settings value, then strips them out. At least this way, you can have your scope working ASAP, plus the change will be backward compatible even once the fix lands.

Something like this:

    function unquote(str)
    {
        if (str[0] === '"' && str[str.length - 1] === '"')
            return str.slice(1, str.length - 1);
        return str;
    }

then later:

    var setting = unquote(scopes.self.settings["location"].get_string());

Changed in unity-api (Ubuntu):
status: New → In Progress
assignee: nobody → Marcus Tomlinson (marcustomlinson)
Changed in unity-js-scopes:
assignee: Marcus Tomlinson (marcustomlinson) → nobody
Revision history for this message
Brian Douglass (bhdouglass) wrote :

Thanks for the update and the suggestion. I'll have to implement something like that.

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Hey Brian, sorry for the really long wait.

The linked branches are finally ready for QA signoff (https://requests.ci-train.ubuntu.com/#/ticket/1129).

I'm hoping it won't be too long now for the fix to be released.

Changed in canonical-devices-system-image:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Alejandro J. Cura (alecu)
milestone: none → 11
Revision history for this message
Brian Douglass (bhdouglass) wrote :

Wonderful, thank you for getting this fixed!

Changed in unity-scopes-shell (Ubuntu):
status: In Progress → Fix Released
Changed in unity-api (Ubuntu):
status: In Progress → Fix Released
Changed in canonical-devices-system-image:
status: In Progress → Fix Released
Changed in canonical-devices-system-image:
status: Fix Released → Fix Committed
Changed in unity-api (Ubuntu):
status: Fix Released → Fix Committed
status: Fix Committed → Fix Released
Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.