Where does url-quoting of links happen?

Hi,
I have markup like this in a PageTemplate:

<a href="solutions-#{1}">XX</a>

(I need this kind of syntax, since it is used by pat-clone (http://patternslib.com/clone).)

But what gets rendered in the browser (-> "view source") is this:

<a href="solutions-#%7B1%7D">XX</a>

That means, the curly brackets got percent-encoded / url-encoded.

This kind of replacement only seems to happen with strings that are part of an href. If I place the same string into an attribute like id or as text into any tag, the syntax is preserved.

I would love to get a pointer on where in the code of Plone this treatment of links is happening, so that I can work on a solution for my problem.

Thanks!
Wolfgang

Could it be lxml?
Try poking around in https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/transform.py#L138 to see if that's true

Hi,
which addons are installed?
I cant reproduce your issue on fresh plone5.1

Maybe a chameleon "feature"/bug

Not really related to the question (and probably a bad idea), but could it be possible to make a workaround by using tal:attributes if it has something to do with chameleon ?

Thanks for all the hints so far. I can confirm, on a standard Plone5 (5.1) installation, this is not a problem.

My site is somewhat special since it uses Chameleon and NuPlone, and due to the latter (and the use of Euphorie), I have only a very reduced set of Plone management screens (ZMI is fully functional though).

I saw that the the transform in theming is not used, and neither did I see Chameleon mangle it (in the return value of render() in https://github.com/malthe/chameleon/blob/master/src/chameleon/zpt/template.py#L297 the curly brackets are still intact.)
Completely deactivating JavaScript also makes no difference.

EDIT: and setting the href with tal:attributes also makes no difference.

I will keep digging... and post my findings here.

Update: @jaroel was right, it happens via lxml. But in a different spot.

Details: In ZPublisher.Publish.publish(), there's a call to notify(PubBeforeCommit(request)), which leads to plone/transformchain/zpublisher.py(86)applyTransformOnSuccess(). One of the handlers that act upon that event is plone.protect.auto.ProtectTransform.

So in the end, we land here:

Up until here, the result contains the href with the curly brackets intact. But when the html.tostring serializer gets applied, the curly brackets get replaced in the href when result is rendered.

The fact that I even land in this part of the code (versus stock Plone 5.1), is because the handler before that, "plone.app.theming.transform" does nothing. Therefore, result is still in the original state that gets passed in to plone.transformchain.transformer, that means a list of strings.
In stock Plone 5.1, "plone.app.theming.transform" does indeed return output, so by the time the transformer is called in plone.protect, result is an instance of XMLSerializer, and the lxml transform (html.tostring) never happens, because of

So finally, I think I have an idea what to do in my custom site to circumvent that problem.

Edit:
And of course this leads me back to Roel's suggestion about


which in my case is not used, because the theme itself is not enabled...

1 Like

Plone5 always transform your content, except it has no styling :slight_smile:

Hi,
maybe plone.tile

or
NuPlone's own cleaning....