Added whitespaces where missing in the restricted file message.
Closes T15270
Differential D25419
Fix the whitespace issue in the message "Access Denied: Restricted File" roberto.urbani on Aug 23 2023, 07:49. Authored by Tags Referenced Files
Details Added whitespaces where missing in the restricted file message. Closes T15270 Access a forbidden file. Check whitespaces in the error message.
Diff Detail
Event TimelineComment Actions Updating D25419: Fix the whitespace issue in the message "Access Denied: Restricted File" Comment Actions Updating D25419: Fix the whitespace issue in the message "Access Denied: Restricted File" Fixed a linting issue, the line was too long so the build was failing Comment Actions Thanks. I would like to help in reviewing but I don't get the difference. Can you describe the inline change? Comment Actions 0. Welcome!
Comment Actions It seems your "master" branch has (many?) local unexpected commits. In order to work on this feature, in Phorge, try these: git status # you should be on master - please eventually manually delete any local uncommitted change Then, create another clean branch: git branch pippo_feature git switch pippo_feature git reset --hard origin/master So now you are on a custom branch pippo_feature that is super-clean. From there you can add fresh features and propose whatever patch. (To switch between branches, just git switch master or git switch pippo_feature ecc.) Comment Actions Updating D25419: Fix the whitespace issue in the message "Access Denied: Restricted File" Adding spaces directly where describeAutomaticCapability is called Comment Actions Nice catch I'm not 100% sure but maybe it's the consumer of getSpecialRules() that should do that. Maybe here: What do you think about? Comment Actions What do you think about the related tip? Also here I can maybe try to propose a counter-patch next week Comment Actions @valerio.bozzolan I actually think the right place to look at the usage of getSpecialRules() might be here: https://we.phorge.it/source/phorge/browse/master/src/applications/policy/filter/PhabricatorPolicyFilter.php;4f845d8f8c77$693-719 I don't know exactly what to change there, though. I see the $text_details = implode(' ', $text_details); which seems to be doing the right thing, but that variable is then used in the exception's full message, whereas the $html_details is constructed as merely array($head, $more, $exceptions); and then used as setMoreInfo($html_details);. I see also the usage of this PhabricatorPolicyException::setMoreInfo() sets the moreInfo class member which is then read by PhabricatorPolicyException::getMoreInfo(), in particular here: https://we.phorge.it/source/phorge/browse/master/src/aphront/handler/PhabricatorPolicyRequestExceptionHandler.php;9481b9eff111$58-84 — which is weird, because the AphrontDialogView::appendList() method, which is called there, appears to produce an <ul> tag, as per the code in defined in https://we.phorge.it/source/phorge/browse/master/src/view/AphrontDialogView.php;a89b4ff5b8bc$226-243. So I'm a bit lost at this point... Comment Actions
I suspect that was/is there to allow $exceptions to have fancy HTML content, but if there is any fancy HTML content in there, the result of $text_details = implode(' ', $text_details) would end up strange (and be text anyway. and maybe start throwing/warning in php 8?). I wish we had more static typing.
The value of moreInfo here is a list (array) of 3 things, (https://we.phorge.it/source/phorge/browse/master/src/applications/policy/filter/PhabricatorPolicyFilter.php;4f845d8f8c77$702) - $head, $more and $exceptions, and I'm guessing from context that the appendList() creates one <ul> for the list and one <li> for each item in the list - so $exceptions at this point is a single thing. Anyway, I think it would be ok to assume that getSpecialRules should return a "list of strings", and then either implode it in habricatorPolicyFilter, or go with the added whitespace as currently suggested here.
Comment Actions Oh! Yeah, that makes sense, thanks for the clarification!
So would the latter option mean doing $html_details = array($head, $more, implode(' ', $exceptions)); here? I kind of find this approach cleaner than appending a space to each item in the $exceptions array. Comment Actions
Yeah, exactly. Comment Actions Should I go ahead and submit a different patch? Or could I somehow contribute the edit to this patch? Comment Actions @waldyrious: I think you could ./arcanist/bin/arc patch D25419, make changes, and then ./arcanist/bin/arc diff --update D25419 to push an updated version. Comment Actions (In the meanwhile, removing the red semaphore, since the goal was to attract reviewers and it worked asd) Comment Actions Thanks for the note, Andre! I've went ahead and updated the revision as discussed above. Comment Actions I can confirm that this patch fixes the string problem. However, I am super super puzzled that after applying this patch, the CSS definition line-height: 22px for .phabricator-wordmark is suddenly missing in both Chromium 120 and Firefox 120, moving the wordmark a bit higher in the upper left corner (on my two screenshots, that is "Phoriorge"). Comment Actions That's so weird! My instinct is of course to say that it should be completely unrelated to this patch since no CSS is touched in this one-line change... I have no idea how to debug this ☹️ Comment Actions I believe I had some weird aggressive local browser cache pollution with rPaa8af1d79e8bfeb09e72d5e3b9330780e78b7aeb as I cannot reproduce the wordmark problem anymore, so: LGTM Comment Actions On the other hand, as the variable is called $html_details let's go for phutil_implode_html() to be super-safe? ping @roberto.urbani Comment Actions Thanks for the recommendation, Andre! I conferred with @valerio.bozzolan and he agrees, too. I have updated the patch. Below are the screenshots of the result: Before: After: |