Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgInvoke data parsing add or check for " around data string #138

Open
olzzon opened this issue May 23, 2019 · 6 comments
Open

cgInvoke data parsing add or check for " around data string #138

olzzon opened this issue May 23, 2019 · 6 comments

Comments

@olzzon
Copy link
Contributor

olzzon commented May 23, 2019

When passing a string with the cgInvoke command, the string will be ignored by CasparCG unless it is surrounded by a "
So this won´t work:

ccgConnection.cgInvoke(1, 19, 1, "mainStrap(true, 'foo', 'bar')")

To parse the data to AMCP one needs to add a " on both sides of the string:

ccgConnection.cgInvoke(1, 19, 1,  '"' + "mainStrap(true, 'foo', 'bar')"  + '"');

Best solution would be that the modules formats the AMCP command with the " added.
Otherwise a string checker should be added, and return an error if string is not correct formatted?

@jesperstarkar
Copy link
Member

It should be simple to add surrounding ", but that needs to escape the inner ones too.

@olzzon
Copy link
Contributor Author

olzzon commented May 23, 2019

From my trying this mornings, it seems that for CasparCG to accept it, the inner ones has to be ‘
And the outer ones has to be “

@Julusian
Copy link
Member

Escaping " and ' is not a simple task I have found. It is definitely possible to use " inside the string, as I often pass in JSON which needs those.
But I think it comes down to needing a annoyingly large or weird number of slashes before each one.

@olzzon
Copy link
Contributor Author

olzzon commented May 23, 2019

As the inner ones has to be ' and the outer ones has to be " then there should be no need for escaping.
Just a checker for the inners to be ' and a checker for the outers to be " and adding the outers if not present.

@mint-dewit
Copy link
Contributor

As the inner ones has to be ' and the outer ones has to be " then there should be no need for escaping.

You say that but you can't guarantee that will work for every use case.

An appropriate AMCP command (escaped) looks like this: CALL 1-20 INVOKE "test({\"f0\":\"an example of \\\"my test's\\\" subject\"})"\r\n

Note here how the json " are escaped, and the inner texts " have to escape the escape as well

Also note how assuming the inner quotes will always be ' doesn't work in this case simply because that is not valid JSON.

@olzzon
Copy link
Contributor Author

olzzon commented May 23, 2019

Yeah, I see, you´re right, I was a little quick concluding that.
Anyway, I just try to find a way to help the next one with this, as I did spend the most of the morning trying to figure out why it wasn't´t doing as expected. It was the first time I used invoke so I was assuming a lot of things.
So maybe we just should add a comment (for the docs)
Something like:

/*
** The method string needs to start and end with a "-sign, otherwise CasparCG will ignore the method.
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants