Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Unclosed brackets in strings #196

Open
HybridAU opened this issue Apr 21, 2020 · 0 comments
Open

Unclosed brackets in strings #196

HybridAU opened this issue Apr 21, 2020 · 0 comments

Comments

@HybridAU
Copy link

HybridAU commented Apr 21, 2020

Using code that has an unclosed bracket inside a string can cause a 500 server error. For example the test

from golem import actions

def test(data):
    actions.get("https://www.google.com/search?q=unclosed)bracket")

The problem seems to be that the _replace_substrings function sees the open bracket from the get function and matches it with the close bracket in the string resulting in actions.get("5a8c9aaa-b87b-4a28-8a91-1c3db5de2d13")bracket")

I've got a few ideas about how to fix this but I'm not sure what the best approach is;

  • Add a check replace quoted strings before replacing brackets, I think this is the best solution but worry it might introduce new bugs with quotation marks.
  • Add a check to see if the number of brackets is balanced, and if not handled it somehow.
  • In the _replace_substrings function, work from the outside in, so when looping through look for the ( with code[i] and look for the ) with code[-i]. The problem with that is a string like this is (a) (test) string would end up as this is ("5a8c9aaa-b87b-4a28-8a91-1c3db5de2d13") string and I'm not sure if that would break things.
  • Maybe some other approach?
@HybridAU HybridAU changed the title Unclosed bracer in strings Unclosed brackets in strings Apr 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant