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

Run Keyword And Return does not escape return values correctly #1684

Closed
spooning opened this issue Jun 30, 2014 · 4 comments
Closed

Run Keyword And Return does not escape return values correctly #1684

spooning opened this issue Jun 30, 2014 · 4 comments
Assignees
Milestone

Comments

@spooning
Copy link
Contributor

Originally submitted to Google Code by andrey.hitrin on 21 Mar 2014

Hello!

Documentation for the keyword 'Run Keyword And Return' claims that following code samples should be equivalent to each other:

Run Keyword And Return  My Keyword  arg1    arg2

and

${result} =     My Keyword  arg1    arg2
Return From Keyword     ${result}       

But it is not true when "My Keyword" returns string that contains some text that may look like Robot Framework variable. In the attached file I demonstrate an example of this. Looks like keyword "Run Keyword And Return" not just simply return given value, but also tries to evaluate it.

What I've got:

$ pybot test.txt

Test

Direct Call With "[Return]" Works Fine | PASS |

Direct Call With "Return From Keyword" Works Fine | PASS |

Old-Fashion Wrapping Works Fine | PASS |

New-Fasion Wrapping Fails | FAIL |

Replacing variables from keyword return value failed: Resolving variable '${client-email}' failed: Non-existing variable '${client}'.

Test | FAIL |
4 critical tests, 3 passed, 1 failed
#4 tests total, 3 passed, 1 failed

$ pybot --version
Robot Framework 2.8.4 (Python 2.7.5+ on linux2)

@spooning
Copy link
Contributor Author

Originally submitted to Google Code by @pekkaklarck on 14 Apr 2014

Interesting. Need to investigate this a bit more thoroughly to understand why this happens and could we fix it.

@spooning spooning added this to the 2.8.5 milestone Jun 30, 2014
@spooning
Copy link
Contributor Author

Originally submitted to Google Code by @pekkaklarck on 22 Apr 2014

The problem is that Run Keyword And Return doesn't escape return values it gets before internally using Return From Keyword to actually return the value. The bug doesn't only cause problems with strings that contain variable syntax, like ${client-email} in the original description, but also any usage of backslashes. Backslashes are unescaped and thus e.g. returned c:\temp turns into c:<tab>emp.

@spooning
Copy link
Contributor Author

Originally submitted to Google Code by @pekkaklarck on 22 Apr 2014

This issue was updated by revision e086f9837c65.

Fixed Run Keyword And Return and that automatically also fixed Run Keyword And Return If. Also added tests for both.

@spooning
Copy link
Contributor Author

Originally submitted to Google Code by andrey.hitrin on 22 Apr 2014

Great! Thank you!

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

No branches or pull requests

2 participants