Skip to content

Conversation

@laoneo
Copy link
Member

@laoneo laoneo commented Jun 13, 2017

Pull Request for Issue #15995.

Summary of Changes

When a category changes for an article the page got reloaded to determine the custom fields. Actually this action got delegated to the com_fields controller. On that point the data is unvalidated stored in the session. This can lead to time shifts when the Joomla timezone is not UTC, more information can be found in issue #15995.

This pr reloads the page trough the component controller and not the com_fields one.

Testing Instructions

  • Set the global Joomla timezone to a different one than UTC, for example Berlin
  • Create two article categories
  • Create a calendar custom field
  • Set show time to yes in the field
  • Save the field
  • Create an article
  • Change the category of the article

Expected result

The time in the custom field remains.

Actual result

The time in the custom field shifts the same hours as the Joomla timezone has.

@ghost
Copy link

ghost commented Jun 13, 2017

I have tested this item 🔴 unsuccessfully on 64d9bb2

  1. Set Time-Zone to "Berlin",
  2. applied PR,
  3. change Category > +2h in Calendar-Field
  4. changed back to 1st Category > additional 2h (4 Hours)

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16665.

@laoneo
Copy link
Member Author

laoneo commented Jun 13, 2017

Do the publishing dates also shift?

@ghost
Copy link

ghost commented Jun 13, 2017

I have tested this item ✅ successfully on 64d9bb2

Test again, all works fine now.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16665.

@wilsonge
Copy link
Contributor

We need to be careful of ACL here - this is going to expose public data if accessed directly from a URL

@laoneo
Copy link
Member Author

laoneo commented Jun 13, 2017

Really, it uses the same code and checks as the save function. Which line do you think can be dangerous?

@Bakual
Copy link
Contributor

Bakual commented Jun 13, 2017

Really, it uses the same code and checks as the save function. Which line do you think can be dangerous?

Maybe I miss something but I don't see any ACL checks at all here.
The save method uses $this->allowSave($data, $key) to check if saving is allowed which I don't see in your reload method.
We may also have to use checkEditId($context, $id) to verify that the item was correctly opened before.

@laoneo
Copy link
Member Author

laoneo commented Jun 14, 2017

Why is the allowSave check needed, it doesn't save, it just reloads the page to an url like /cms/administrator/index.php?option=com_content&view=article&layout=edit&id=1. The checkedit id is done in the controller itself. I mean at the end it performs the same action as when you want to edit the article. If you paste that url directly into the browser and you didn't go trough the edit task, then it kicks you back to the list with a warning to not get directly to the edit page. I'v just tested it and it worked as expected.
If I'm now not completely wrong then I don't understand your points here. What else needs to be checked?

@Bakual
Copy link
Contributor

Bakual commented Jun 14, 2017

Why is the allowSave check needed, it doesn't save, it just reloads the page to an url like /cms/administrator/index.php?option=com_content&view=article&layout=edit&id=1.

It does save the data into the session. It at least feels wrong to have a controller task without any ACL check. Which means anyone could run it. It may not be an issue by itself, but it may bite us back and there is no reason this task should be available unauthorised. Using allowSave or allowEdit (if that fits better due to not saving into db) is a save check we can and should do imho. I don't see a reason to not do it.

As for checkEditId, you're right. I just remembered we check it but didn't remember where exactly 😄

@wilsonge
Copy link
Contributor

Does this not allow accessing data from any JControllerForm instance (including in the frontend (e.g. com_contact)) without checking the published/acl levels for the item though?

@laoneo
Copy link
Member Author

laoneo commented Jun 14, 2017

I don't se how, it only stores the jform data into the session.

@mbabker
Copy link
Contributor

mbabker commented Jun 14, 2017

It is still a POST request receiving user data. It should therefore be properly validated and access controlled. Especially if that data stored into the session can be used in a follow on request (which HAS been used in security issues we have fixed in the last 2 years).

@wilsonge
Copy link
Contributor

The session is data that the user controls. That means the user has the data which they shouldn't have been allowed to access (for ACL reasons) - and even if it isn't displayed on the page. It's trivial to get the session data if you wanted it.

@laoneo
Copy link
Member Author

laoneo commented Jun 14, 2017

Does that help d10e8fc?

@Bakual
Copy link
Contributor

Bakual commented Jun 14, 2017

Imho, the ACL check is now fine.

Looking at the redirects, why don't you just use $this->redirect()? Also $app->close() is useless even when you use $app->redirect() directly, since that method already closes the app. Or do I miss something?

@laoneo
Copy link
Member Author

laoneo commented Jun 15, 2017

Just to be sure. Probably not needed.

@Bakual
Copy link
Contributor

Bakual commented Jun 15, 2017

If there is no specific reason to use $app->redirect() directly, can you just use $this->setRedirect($url, $msg, $type) and $this->redirect() then? So we are consistent with how we process redirects in other places in the controllers.

@laoneo
Copy link
Member Author

laoneo commented Jun 15, 2017

True, done.

@wilsonge
Copy link
Contributor

RE ACL: I'm honestly unsure given what this function does whether it should be edit or read acl permissions we should be using. But this looks significantly better now :)

@laoneo
Copy link
Member Author

laoneo commented Jun 15, 2017

It should check edit, as it belongs to the edit action.

…d-form

# Conflicts:
#	administrator/components/com_fields/helpers/fields.php
@infograf768
Copy link
Member

@laoneo
I can't get the calendar field anymore
( ! ) Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/testnew/trunkgitnew/libraries/cms/helper/content.php on line 74

@infograf768
Copy link
Member

fields

'/administrator/components/com_messages/layouts/toolbar',
'/administrator/components/com_messages/layouts',
// Joomla! __DEPLOY_VERSION__
'/components/com_fields/controllers',
Copy link
Member

Choose a reason for hiding this comment

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

this targetting a folder. Should be the file.
'/components/com_fields/controllers/field.php',

Copy link
Member Author

Choose a reason for hiding this comment

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

This folder has only one file, so better to remove it completely.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Why?

Copy link
Member

Choose a reason for hiding this comment

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

As comment says, deleting only the folder may not work when ftp is used.
It is safer to at least delete the file.

laoneo added 2 commits July 7, 2017 13:27
If a new article is created and the title is not set and the category has changed, then the validated data is false, will not be set and the admin is loosing all its entered data. So we need to filter here only.
@laoneo
Copy link
Member Author

laoneo commented Jul 7, 2017

Good catch. Fixed it in the last commits.

@infograf768
Copy link
Member

Works now. Remains the necessary changes in script.php

@laoneo
Copy link
Member Author

laoneo commented Jul 8, 2017

Ok, done.

@infograf768
Copy link
Member

I have tested this item ✅ successfully on fb925e7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16665.

1 similar comment
@ghost
Copy link

ghost commented Jul 9, 2017

I have tested this item ✅ successfully on fb925e7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16665.

@ghost
Copy link

ghost commented Jul 9, 2017

RTC after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jul 9, 2017
@infograf768 infograf768 added this to the Joomla 3.7.4 milestone Jul 9, 2017
@laoneo
Copy link
Member Author

laoneo commented Jul 9, 2017

Thanks guys!

@rdeutz rdeutz merged commit 0774500 into joomla:staging Jul 9, 2017
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jul 9, 2017
@laoneo laoneo deleted the cf/reload-form branch July 9, 2017 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants