Error in sharepoint url containing {}

0 votes
asked Mar 23, 2021 in Bug by ggmimi (240 points)
Hello,

Some sharepoint url containg {} in hyperlink are not well formatted because all text between {} is considered as tooltip

Would it be possible to use a pragma to change tooltip delimiter ?

here is an example with corrupted sharepoint url :

@startuml

component EX_GIT_14 as EX
(Traiter demande) <-- EX
card "Développer lancement batch à \ntravers transactionnel" as 44
44 <.. (Traiter demande) : << étape (44) >>
FABRICANT_DEV <-- (44)

note top of EX
    Gestion du fichier SAI2
endnote

legend
**Gestion du fichier SAI2**

Le fichier SAI2.txt contient la liste des traitements batch. La livraison de ce composant doit respecter la procédure
suivante :

[[https://recouv.sharepoint.com/:o:/r/sites/SNV2cycledevieconstruction/_layouts/15/WopiFrame.aspx?sourcedoc={fd713f02-1f0e-4c8b-ba91-3b1f8dab02eb}&action=edit&wd=target%28Documentation%2Eone%7C402BFC46%2DCDF5%2D409A%2DBCC3%2DDBEA08FC2289%2FComposants%20SAI2%7C26FCDA2B%2D1AFE%2D45FE%2DA58C%2D8C7BC11DB533%2F%29 Composants SAI2 (Mode web)]]
endlegend
@enduml

Best regards
commented Mar 24, 2021 by Martin (9,120 points)
I think in theory you're supposed to be able to enclose the url in quotes, but it doesn't seem to work.
commented Mar 24, 2021 by ggmimi (240 points)
Indeed, it doesn't work.

It is a pitty, my enterprise moved his documentation from a local wiki to microsoft ecosystem (teams + sharepoint + onenote...) and all links to hyperdoc are no more accessible because of presence of {} in sharepoint url
commented Mar 24, 2021 by plantuml (295,760 points)
We could make a fix to partially accept bracket in URL, as long as the URL does not end with a bracket.

So the following URL would be working: http://foo?dummy={123}&action=edit

But the following won't: http://foo?dummy={123}
(because "123" will be interpreted as a tooltip)

Would that be acceptable ?
commented Mar 24, 2021 by Martin (9,120 points)
edited Mar 24, 2021 by Martin

@Plantuml, I'm curious as to why

[["http://foo?dummy={123}"]] 

doesn't work.  

My desk-reading of urlbuilder.java suggests that quoting the url should populate:

final String quotedPart = m.group(1);

and so use:

return new Url(withTopUrl(quotedPart), null, null);

For my education, what am I missing there?

commented Mar 24, 2021 by Martin (9,120 points)
edited Mar 24, 2021 by Martin

PS, I was wondering whether

private static final String URL_PATTERN = "\\[\\[([%g][^%g]+[%g])?([\\w\\W]*?)\\]\\]";

should be changed to:

private static final String URL_PATTERN = "\\[\\[(?:[%g]([^%g]+)[%g])?([\\w\\W]*?)\\]\\]";

So that the quotes are not captured in the first capture grouping.  Plus it might play better with "topurl" too.

commented Mar 24, 2021 by Martin (9,120 points)

Ah, ok, you're going to have to remove the test for "{" in URL.java :

public Url(String url, String tooltip, String label) {
if (url.contains("{")) {
throw new IllegalArgumentException(url);
}
commented Mar 24, 2021 by plantuml (295,760 points)

The hard part is that some people want to put Json data in the tooltip, and it should also be possible to use "scale" syntax in the label part.

So the following syntax should work:

[[http://www.plantuml.com{Json: {"firstName":"Bob", "lastName":"Smith"}}]]
[[http://foo?dummy={123}&action=edit]]
[[http://google.com <img:HelloWorld.png{scale=2}>]]

I think it's time to completely rewrite to UrlBuilder class to deal all those complex cases...

2 Answers

+1 vote
answered Mar 24, 2021 by anonymous
selected Mar 24, 2021 by ggmimi
 
Best answer

Hello, 

Thank you for this answer!

It would be nice indeed.

I tried to find the sharepoint url specs  but don’t find anything interesting. 

And in my company, i have no exemple of sharepoint url ending with }.

So your answer is very acceptable !

PS : how would behave plantuml if i manually add empty tooltip {} affer a sharepoint url like this : 

http://foo?dummy={123}{}

best regards 

commented Mar 24, 2021 by plantuml (295,760 points)
Yes, http://foo?dummy={123}{} would work in the new version.

Note that in the actual version, you should be able to use quote like this: [["http://foo?dummy={123}"]]

But I guess that changing all your URL is not easy, so you might wait for the new version.
commented Mar 24, 2021 by anonymous
Thank you,

I will wait for the new version.

And unfortunately, i tried enclosing my example url between quotes without succes.

Best regards
commented Mar 24, 2021 by The-Lu (70,400 points)

Hello all,

See also similar request/workaround here: https://forum.plantuml.net/11964/escape-characters-in-links
With escaping { to %7B, and } to %7D...

Regards,
Th.

commented Mar 24, 2021 by ggmimi (240 points)

thanks !

Indeed, this work around solve my problem (escaping { to %7B, and } to %7D) !

but maybe not all use case listed by plantuml team :

The hard part is that some people want to put Json data in the tooltip, and it should also be possible to use "scale" syntax in the label part.

So the following syntax should work:

[[http://www.plantuml.com{Json: {"firstName":"Bob", "lastName":"Smith"}}]]
[[http://foo?dummy={123}&action=edit]]
[[http://google.com <img:HelloWorld.png{scale=2}>]]

I think it's time to completely rewrite to UrlBuilder class to deal all those complex cases...

0 votes
answered Mar 25, 2021 by plantuml (295,760 points)

This is fixed in last beta http://beta.plantuml.net/plantuml.jar and on the online server.

We were not able to manage all cases, and if you want an empty tooltip, you will have to use

[["http://foo?dummy={123}"{}]]
...