BBob icon indicating copy to clipboard operation
BBob copied to clipboard

URL parser does not handle [] in the link

Open celsworth opened this issue 1 year ago • 2 comments

I'm having trouble generating links if the URL has [] in it, which is used in Rails to pass through arrays and hashes. For example, this, an URL like this is not parsed:

https://shalazam.info/maps/1?x=1691.0&y=755.0&zoom=5.0&pin_loc[x]=3440&pin_loc[y]=3716

I can also repreoduce this on the bbob playground with an example as simple as:

[url=https://shalazam.info?loc[x]=1]test[/url]

Parsed to:

[
  "[",
  "url=https://shalazam.info?loc",
  {
    "tag": "x",
    "attrs": {},
    "content": []
  },
  "=1]test"
]

Removing the [x] makes it work.

celsworth avatar Sep 16 '24 06:09 celsworth

I have hit upon a similar problem using the current version of 4.1.1. Could this be a general inability to exclude invalid tags from parsing? In my case (BBob configured for React usage), anything in brackets is converted to either an HTML tag or, depending on case a React component. The latter case even leads to runtime errors, as there is no definition for the supposed React component.

'[tag]' -> <tag> '[Tag]' -> <Tag />

fabiandecuveland avatar Oct 11 '24 12:10 fabiandecuveland

@celsworth as a solution you can encode [] in url in Rails

URI::Parser.new.escape(my_url_string)

or in js

encodeURI(my_url_string)

that leads to https://shalazam.info/maps/1?x=1691.0&y=755.0&zoom=5.0&pin_loc%5Bx%5D=3440&pin_loc%5By%5D=3716

JiLiZART avatar Oct 12 '24 19:10 JiLiZART

So i tried to investigate this problem, but current arch of how parser detects an open and close tags doesn't allow to handle this situation.

For parser tag starts when he find [W (except special chars) and ends when he find ]. There is no way to tell parser that [x] is not a tag.

Only way is to prepare string or url that will be passed to parser. I can't implement source string preparation cause it will be big performance issue for parsser. Main goal of this library is to be small as F and fast as F

JiLiZART avatar Mar 09 '25 12:03 JiLiZART