nextcloud-libraries / nextcloud-vue

🍱 Vue.js components for Nextcloud app development ✌ https://npmjs.org/@nextcloud/vue
https://nextcloud-vue-components.netlify.app/
Other
217 stars 85 forks source link

URL pattern only accepts urls with domain #3930

Open Rello opened 1 year ago

Rello commented 1 year ago

the smart widget validation is using this URL pattern to decide if a URL should be send to the resolver.

https://github.com/nextcloud/nextcloud-vue/blob/af25af897a22410fc04cdbb140253cc3c28b520e/src/components/NcRichText/helpers.js#L1

used here https://github.com/nextcloud/nextcloud-vue/blob/0390767fb52de625655f2bc5b255028495945986/src/components/NcRichText/NcReferenceList.vue#L67

my setup is within a local docker and this does not have a domain like .com - so the resolver is never triggered for local urls. Is this on purpose or should it be made more flexible?

julien-nc commented 1 year ago

cc @juliushaertl

julien-nc commented 1 year ago

Hey, the reference manager actually can't resolve local URLs for security reasons. The resolving happens on the server side for which localhost is different than in the browser point of view (except in your case where the browser is on the same host than the server).

What I do is to add a name resolving rule on my local system so for example nextcloud.local resolves to 127.0.0.1.

Rello commented 1 year ago

Hi, not sure if we are talking about the same. I am talking about this call tree, where every post in e.g. Talk is looped and checked against the regex mentioned above - all client side: Bildschirm­foto 2023-03-28 um 15 11 41

Bildschirm­foto 2023-03-28 um 15 12 06

Bildschirm­foto 2023-03-28 um 15 12 20

and this is coming from helper.js. isn´t it?

julien-nc commented 1 year ago

Yes, we're talking about the same thing. The URL_PATTERN is used to decide if we should ask the server to resolve a link or not. Even if we change this to match local IPs, the reference manager on the server side will refuse to resolve those links (provide the data for the preview) anyway. I mean, this regexp is consistent with the check on the server side.

What I do is to add a name resolving rule on my local system so for example nextcloud.local resolves to 127.0.0.1.

What I meant here is that then you can access your local NC instance with nextcloud.local and then the internal links are https://nextcloud.local/apps/whatever/... and the regexp matches and the reference manager accepts to resolve them.

We recently adjusted the other regexp which is used to choose if we render substrings as links or not: https://github.com/nextcloud/nextcloud-vue/pull/3935 There we allow IPs, even local ones.

I hope I made it a bit clearer, did I?

Rello commented 1 year ago

ok, did not know about the backend part...