Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make notes path configurable #207

Merged
merged 10 commits into from
Jul 3, 2018
Merged

Conversation

danielmorlock
Copy link
Contributor

I introduced a user setting where a user can set a custom path for its notes. See "Settings" -> "Additional Settings".

Feedback is welcome!

Copy link
Member

@korelstar korelstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this nice PR! This will fix #57 😃

I had a deep look at your code, and it's very good! However, I found some problems -- I commented them at the respective code line. As a general hint, here are some notes on building secure apps, which should be considered: https://docs.nextcloud.com/server/13/developer_manual/general/security.html

In #57, @jancborchardt suggested to use "a bottom left settings area" like in the files app, contacts app or calendar app. I think this would be better than hiding this setting on the personal settings page. But it should be easy to move your template to the other position.

Looking forward for an update of your PR 👍

js/package.json Outdated
"dependencies": {},
"dependencies": {
"bower": "^1.8.4",
"grunt": "^1.0.3"
Copy link
Member

@korelstar korelstar Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that those dependencies are required. For me, it works without them.

@@ -0,0 +1,5 @@
<form id="notesSettings" class="section">
<h2>Notes</h2>
<p class="settings-hint">Set the default path to store your notes.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These strings must be internationalized. Please use:

<?php p($l->t('Set the default path to store your notes.')); ?>

<form id="notesSettings" class="section">
<h2>Notes</h2>
<p class="settings-hint">Set the default path to store your notes.</p>
<input type="text" name="notesPath" value="<?=$_['notesPath']?>" placeholder="Notes" id="notesPath" style="width:100%"/>
Copy link
Member

@korelstar korelstar Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value must be sanitized. Currently, you could do a XSS attack! Please use p(...) for this.

<form id="notesSettings" class="section">
<h2>Notes</h2>
<p class="settings-hint">Set the default path to store your notes.</p>
<input type="text" name="notesPath" value="<?=$_['notesPath']?>" placeholder="Notes" id="notesPath" style="width:100%"/>
Copy link
Member

@korelstar korelstar Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice, if also pressing return would save the setting. Currently, only putting the focus to somewhere else does work.

@@ -295,7 +300,8 @@ private function getFileById ($folder, $id) {
* @return Folder
*/
private function getFolderForUser ($userId) {
$path = '/' . $userId . '/files/Notes';
$notesPath = $this->config->getUserValue($userId, 'notes', 'notesPath');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we need to have a fallback to the default value Notes if there is no such setting, yet.

public function setNotesPath($notesPath) {
$uid = $this->userSession->getUser()->getUID();

$path = '/' . $uid . '/files' . $notesPath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be '/files/'

public function setNotesPath($notesPath) {
$uid = $this->userSession->getUser()->getUID();

$path = '/' . $uid . '/files' . $notesPath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should sanitize $notesPath before using it here. However, I wasn't able to attack this. Does the Files API checks for directory traversals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find anything about this in the dev docs. The closest info I've found is this: https://github.com/nextcloud/server/blob/stable13/lib/public/Files/Folder.php#L104
Since the path was not "manually" sanitized before my changes, I did not sanitize them, too and I assume that this is done internally. But you're right, this should be verified - but I think I'm not the right person to do so :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I analyzed this and found out that the nextcloud-server sanitizes the path. Hence, it's not a security problem, but maybe a usability problem.

@jancborchardt
Copy link
Member

Yup, like @korelstar said, this should be in a bottom left settings area. You can find the design documentation on that at https://docs.nextcloud.com/server/14/developer_manual/design/settings.html :)

@jancborchardt jancborchardt added enhancement New feature or request design Related to the design or user experience labels Jun 21, 2018
@danielmorlock
Copy link
Contributor Author

@jancborchardt I've introduced the app settings in the bottom left. Further I did some work on making the settings management more abstract in order to support possibly other app settings next to "notesPath".

@korelstar
Copy link
Member

Thanks! That looks good to me:

grafik

grafik


The personal settings page is obsolete now and should be removed. I will do a code review again, then (if @jancborchardt has no change requests).

@danielmorlock
Copy link
Contributor Author

@korelstar I've removed the obsolete settings page.

@korelstar
Copy link
Member

Thanks, @danielmorlock !

One last thing:

After changing the setting, nothing (visible) happens. It would be helpful, if the notes app would reload in order to make the new path effective. Can you add this functionality, please? After that I will merge this PR (if @jancborchardt doesn't intervene until then).

Copy link
Member

@korelstar korelstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for bothering you, @danielmorlock . I made the changes by myself. I think it's fine, now.

@jancborchardt
Copy link
Member

Is it also possible to make the setting apply without a reload? :)

@korelstar
Copy link
Member

Indeed, that would be nicer. That would require some more work. I think you should open a new issue for that.

@korelstar korelstar added this to the 2.4.0 milestone Aug 2, 2018
@HarleyStone
Copy link

In looking at the Android app, I'm unable to locate the Advanced options within settings. Currently running 0.27.1 Thanks.

@stefan-niedermann
Copy link
Member

Hi @HarleyStone,

this option is only available via the web interface.

@korelstar is there a REST-API for this setting?

@HarleyStone
Copy link

Hi @HarleyStone,

this option is only available via the web interface.

@korelstar is there a REST-API for this setting?

Ahhh. I see now. Thanks.

@korelstar
Copy link
Member

@korelstar is there a REST-API for this setting?

No. Do you think we need this? I would say, that a setting in the server app is sufficient, isn't it?

@stefan-niedermann
Copy link
Member

Not sure. Noone asked until now and it is something you will usually do max. 1 time, so.... No.

If there was an API, i might have implemented a setting, but it's not worth the effort i think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Related to the design or user experience enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants