Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
block.module
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
27 Jan 2008 at 16:55 UTC
Updated:
29 Jul 2014 at 17:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
decafdennis commentedHere is a patch for HEAD.
Comment #2
decafdennis commentedThe patch still applies to HEAD. Since it's such a simple patch and mimics the behavior of system.module (not using
check_plainin menu item titles) I think it's safe marking this as RTBC.Comment #3
gábor hojtsyWhere is the second check_plain() applied? I tried and reproduced this with Garland, so it is in itself a core issue. Note that at other places, we also do check_plain, but we assign "check_plain" as the title callback instead (eg. with node type names). Are those affected as well?
Comment #4
decafdennis commentedAs far as I can tell menu item titles are ultimately always run through
check_plain()inl(). (Viatheme_menu_item_link()ortheme_links().)Still, I am unsure why the create content menu items do not appear to be affected although their title callback is set to
check_plain.Comment #5
bsimon commentedThis is an old issue, but I'm still seeing the same effect in Drupal 6.6. An apostrophe/single quote ' in a theme name is displayed as ' and a double quote " becomes "
This only affects /admin/build/block, I think. On all other admin pages, the theme name is displayed correctly
This issue appears in all themes that I've tried, including Chameleon and Garland. The theme with the problem name is a subtheme based on Zen. The .info file for the theme is saved as UTF-8 by the editor.
I tried a few other characters (like `~, and even some Chinese), but only ' and " caused problems - maybe it's something to do with 'smart' quotes?
This is only a cosmetic problem in the blocks admin ui. it doesn't seem to have any impact on the site, so I haven't tried the patch.
(I have the i18n module installed, in case that has some relevance to this).
edit: html was parsing character entities
Comment #6
decafdennis commentedThis is still in issue in 8.x-dev. See attached screenshots.
Comment #7
dcam commentedHere's a patch for 8.x. This will probably need to have tests added.
This was my test proceedure:
Copy Bartik to sites/default/themes.
Change the theme name to something with an HTML escaped character, including renaming the directory to a machine name (cats_dogs), renaming the .info file (cats_dogs.info), and the name property in the .info file (Cats & Dogs).
Enable the theme. It's not necessary to set it as the default.
Check the links in the block admin page.
Apply the patch.
Check that the links are now correct.
Comment #9
dcam commented#7: block-links-214760-7.patch queued for re-testing.
Comment #10
kscheirerBug as described exactly in #7 still exists, patch works as advertised.
The last thing this patch needs is a test, and then it's ready to go in! Test that when a theme uses check_plain() unsafe characters in its name, the links on the block admin page (admin/structure/block/list/foo_bar) did not get mangled. And remember to clear your drupal cache after changing the theme's name before you try to enable it.
What are check_plain() unsafe characters? It's really just a call to htmlspecialchars(), which converts:
Setting to needs work for a test, but otherwise this is RTBC.
Comment #11
lokapujyaI'll write the Test for this.
Comment #12
lokapujyaIn order to write a test for this fix, the theme has to be set to visible (in order for it to show up on the in the links on the block admin page.) Usually, test themes are hidden. Will it be a problem if I have a theme that is not hidden? (I think it doesn't matter for D8 because I don't see the theme showing up outside of testing.)
Also, do we really need a test case for this?
Comment #13
lokapujyaI will try creating a test module which implements system_info_alter then to make it not hidden for that test alone.
Comment #14
lokapujya#7: block-links-214760-7.patch queued for re-testing.
Comment #16
lokapujyaReroll. Test Case coming soon.
Comment #17
lokapujyarun simpletest.
Comment #18
lokapujyaComment #19
lokapujyaworking on the testcase.
Comment #20
lokapujyaAdded a Test.
Comment #22
lokapujyaremove single quote test
Comment #23
lokapujyarun simpletest
Comment #25
lokapujyaJust testing to see if this test works on the simpletest server.
Comment #27
lokapujyaNew theme was in the wrong directory. This patch is just to test that simpleTest finds the theme.
Comment #28
lokapujyaFile wasn't attached.
Comment #29
lokapujyaHere is a candidate for review.
Comment #30
lokapujyaRegarding the test:
1. I threw all the special characters into one test. Does that seem reasonable or should they be broken out?
2. Created a new hidden theme. Is that acceptable?
3. I would have preferred to use assertLink(), however assertLink() uses xpath and wasn't able to escape single quotes.
Comment #31
benjy commentedI tested and the issue still exists, patch needs re-roll, looking over the code it looks good apart from below.
Spaces after the commas?
Comment #32
lokapujyaRerolled and added spaces as suggested in #31.
Comment #34
lokapujyamodule_enable was removed.
Comment #35
ceardach commentedRemove "Needs reroll" because new reroll is passing.
Remove "Needs tests" because patch includes tests.
Comment #36
benjy commentedmodule_enable has been removed.
Use \Drupal::config()
Comment #37
benjy commentedComment #38
lokapujyaYes, the patch actually needed a reroll as of 10/24 where the routing was moved to a .yml file: Issue #2102125: Big Local Task Conversion.
Comment #39
lokapujyaComment #40
lokapujyaComment #41
benjy commentedThis is all indented incorrectly.
Also the issue is now fixed in core, however this does add a valid test for the previous problem so it's still worth adding IMO.
Comment #42
benjy commentedComment #43
damien tournoud commentedThis feels like the fix is in the wrong place. If
info['name']is plaintext, why are we converting it to HTML too early?Comment #44
lokapujya@benjy - Part of it is fixed in Core. But, the Theme Name that comes after "Demonstrate block regions" is still double escaped. For example: Demonstrate block regions (Cats & Dogs). So, probably an assertLink test should be added on admin/structure/block/list/cats_dogs.
@Damien Tournoud - I'm not not sure how else to fix it. But that fix works. Not sure what you mean.
Comment #45
lokapujyaComment #46
lokapujyaComment #47
lokapujyaSo, the patch still fixes this issue: admin/structure/block/list/cats_dogs
Before

After:
Comment #48
lokapujyaFixed the whitespace issues from comment #41.
Couldn't add the assertLink that I mentioned in #44, because the "Demonstrate block regions" text doesn't show up in Simpletest. I only noticed the unescaped text shown in #44 by moving the cat_mouse test theme to /themes (to a Drupal branch without this patch, of course) making it unhidden and going to it's block page.
Comment #49
ergophobe commentedJust as a heads up for backporting to Drupal 7 once this is set for D8 (I assume that's the plan).
In D7, it's still necessary to handle the local task that was in #34, but removed for #39
Comment #50
lokapujyaThanks, should I go ahead and start on the D7 patch or wait for this to be reviewed? or is anyone else interested in doing the backport?
Comment #51
lokapujya48: 214760-48.patch queued for re-testing.
Comment #53
lokapujyaNeeds a Reroll.
Comment #54
lokapujyaRe-rolled.
Comment #56
lokapujyaremoved a call to menu_router_rebuild().
Comment #57
lokapujyaProbably better to keep the menu rebuild. In runtime code, rebuild() would probably not be called directly but in a simpletest you need it done immediately.
Comment #59
lokapujya57: 214760-57.patch queued for re-testing.
Comment #60
lokapujyaI don't get that error locally. Retesting.
Comment #61
lokapujyaComment #62
Jalandhar commentedUpdating with reroll. Please review.
Comment #63
mikemiles86Reviewed patch (looks good) and ran the test with success!!
Agree with earlier comments by benjy that even though this problem has been fixed in core, it would be great to have a test for it included as well.
Comment #64
mikemiles86Comment #66
webchickNice catch! And a test to boot. :)
Committed and pushed to 8.x. Thanks!
Moving down to 7.x.
Comment #67
sunHm. I first thought it would be a minor oversight only (
hook_system_theme_info()being gone), but after further review, I think we need to revert this and ensure that we get the tests right:hook_system_theme_info() no longer exists.
No replacement required.
Due to that, the test also does not have to install block_test module anymore.
Can we rename at least the internal theme to properly identify and describe what its use-case is? E.g.:
block_test_specialchars_theme
It's not clear to me why block_test_theme is enabled in this test?
Why is the default theme and admin theme changed to Seven in the test?
The Appearance page does not belong to Block module (and nothing is asserted), so this request is unnecessary.
The admin/structure/block page actually shows the theme name multiple times, and this test does not assert all instances.
In fact, since the test explicitly changes the default theme to Seven instead of the new test theme, this page only shows the theme name in the tabs, but the "Demonstrate block regions" link does not appear for the test theme.
These regions do not seem to be used?
Comment #68
sunComment #69
lokapujyasun: I agree with all points. It might be easier to just patch 8.x? Thanks, the point #6 in that review helped a lot. Led me to figure out why "Demonstrate Regions" did not show up in Simpletest. I needed to add the system_help block.
I think the theme name shows up in 2 places. I added an assertLink to test the one in "Demonstrate Regions".
Comment #70
sunThanks!
The patch doesn't fully address #67 yet:
#67.1: the test also does not have to install block_test module anymore.
#67.3: instead of seven + block_test_theme, the test now enables bartik, which is equally unnecessary.
#67.4: The system.theme configuration doesn't have to be changed for this test.
#67.5: /admin/appearance is still requested.
#67.6: The test enables the Help block now (which contains the faultily escaped link), but it still doesn't ensure that the assertion is not a false-positive. The theme name appears more than once on the block admin pages (in tabs). The test needs to request the block admin (tab) page of the test theme, so that the "Demonstrate block regions" link actually appears on the page.
#67.7: The regions_hidden definition is unnecessary.
Comment #71
lokapujyaOK, some of those missing items were due to a patch creation mistake. So, I'm doing an assertText() on the block page to handle the text in the tab. Then, on the block/list/[theme] page, I'm doing an assertLink() to handle the "Demonstrate Regions" text.
Comment #72
sunThanks, that looks much better now :-)
Given that the router is manually rebuilt one line below, is the
resetAll()actually needed?Both
assertText()andassertLink()are parsing the raw HTML page content on their own, and the string that is passed to the methods is escaped for HTML.In both cases, we should assert the raw page output, like this:
(same for the link; it is sufficient to assert the link text only)
This asserts that we find the exact raw string in the raw page output, without any additional layers of HTML parsing/escaping of the testing framework.
Comment #73
lokapujyasun: I agree that resetAll() is not needed anymore. I also followed your suggestion on the assertRaw() because it minimizes the amount of parsing that is needed. I also tested reversing the "Fix" to verify that the test still fails without the fix.
Comment #74
sunThanks! — Looks good, but the patch contains some file chmod/permission changes:
Comment #75
sunFixing that mistake by simply removing the hunks from the patch.
RTBC if testbot fails on the test-only patch only.
Comment #77
webchickWhoops, thanks for that. Committing at sprints is dangerous. ;)
Committed and pushed to 8.x. Thanks!