Accessing labels/buttons with single quotes/apostrophes in them

35 views
Skip to first unread message

David van der Bokke

unread,
Jun 17, 2011, 12:29:24 PM6/17/11
to Frank
I have been having trouble accessing labels or buttons with text that
has single quotes/apostrophes. An example query would be:

label text:'David's Things'

The problem is obvious which is that apostrophes are used to delimit
the query, but also used in the text itself. I tried escaping the
single quote but that ended up being stripped by Ruby when it sent the
JSON request.

I have a solution that involves an update to UIQuery.m, but it assumes
that the user will only ever have one single quoted string in the
request and nothing after it. Has anyone come up with a better
solution?

Pete Hodgson

unread,
Jun 24, 2011, 4:32:47 AM6/24/11
to frank-...@googlegroups.com
Apologies for the late reply....

I've been frustrated with this myself from time to time. I looked into the UISpec code briefly in the hope of finding a fix, but I was never quite motivated enough to actually find a proper fix.

Ideally I'd like the ruby code to escape single-quotes at some point before serializing to JSON, and have the UIQuery code unescape. If you have something that gets us part of the way there then I'd encourage you to at least put it up in a branch on github in order to get the ball rolling...

David van der Bokke

unread,
Jun 24, 2011, 8:40:45 AM6/24/11
to Frank
Yeah.. I have something I hacked together that makes it work as long
as there is only a single argument with single quotes and it happens
to be the last item in the query. It is an edit to UIQuery.m. It
basically takes the array of strings that UIQuery split apart and
turns the remainder of the array into a single string with single
quotes in it.

It works for cases like: label text:'David's Stuff'
Or even: tableView label text:'David's Stuff'

It just won't work for cases where you have additional text after the
quoted string. Although I haven't had to use any cases like that yet.

I will try to clean it up and push it later today.
Reply all
Reply to author
Forward
0 new messages