Posted by urbanfalcon on October 27, 2005 at 2:29pm
Jump to:
| Project: | Htmlarea |
| Version: | 4.6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I was trying to use htmlArea/Xinha on my system and I couldn't figure out why it didn't show on pages with extended querystrings. Keep in mind, I have cleanURLs on, but my page's URL was like: http://domain/node/123/edit&variable=1 . Due to the use of drupal_get_path_alias directly on $_GET['q'], however, an error was being thrown and htmlArea was being disabled. Here's the fix:
In htmlarea.module around line 759:
Find:
function _htmlarea_is_changed($name = '') {
global $user;
static $textarea;
if (_htmlarea_bad_browser() || (isset($user->htmlarea_isenabled) && $user->htmlarea_isenabled == 0) || (!isset($user->htmlarea_isenabled) && !variable_get("htmlarea_user_default", true)) || !_htmlarea_get_jsdir()) {
return false;
}
$path = drupal_get_path_alias($_GET['q']) .'.';Replace with:
function _htmlarea_is_changed($name = '') {
global $user;
static $textarea;
if (_htmlarea_bad_browser() || (isset($user->htmlarea_isenabled) && $user->htmlarea_isenabled == 0) || (!isset($user->htmlarea_isenabled) && !variable_get("htmlarea_user_default", true)) || !_htmlarea_get_jsdir()) {
return false;
}
//old path doesn't like long querystrings
//$path = drupal_get_path_alias($_GET['q']) .'.';
$querystring = $_GET['q'];
//clean off any querystring junk to get correct path
if (strpos($querystring,"&")){
$querystring = substr($querystring, 0, strpos($querystring,"&"));
}
$path = drupal_get_path_alias($querystring) .'.';And voila...it's robust again. This may be useful for others working in modified environments.
Comments
#1
I cannot replicate the issue that you describe. Can you please expand on how you get this to happen.
#2
Well, I have a module called taxonomy_crumbs which keeps a "sticky" navigation in the left sidebar depending on which taxonomy page was last visited (ie., http://www.mydomain.com/taxonomy/term/2). In order to keep the navigation sticky within reason, it employs a querystring variable. Therefore, going to the above URL and clicking on a node link for node #1234 would send you to http://www.mydomain.com/node/1234&breadcrumb=2. In order keep the left navigation area in place through an edit, the breadcrumb persists. So in an edit, the url would be http://www.mydomain.com/node/1234/edit&breadcrumb=2 - which disables Xinha. The reason it disables Xinha is because of the use of drupal_get_path_alias on the entire $_GET['q'] line (ie., q=node/1234/edit&breadcrumb=2) versus just the "core" information (ie., q=node/1234/edit). Since q is in fact a querystring variable, instead of cleaning off everything after "?" in the querystring, we just need to clean off everything after the first "&" in function _htmlarea_is_changed. Which makes it robust enough to work once more.
#3
Taking a look at this it is not a valid url which is why it is stuffing up.
The url should be http://www.mydomain.com/node/1234?breadcrumb=2 instead of http://www.mydomain.com/node/1234&breadcrumb=2
#4
I believe I tried it both ways to no avail. The problem with what you've suggested is that clean urls (and path alias?) uses a server mod that masks the url path, and some php global variables still "see" the original version. Regardless of whether clean urls are turned on or off, anything tacked onto the end of the visible url created by drupal needs to start with "&." I believe you'll find the same thing with the "destination" variable that is already in use from time to time.
This is the true url:
http://www.mydomain.com?q=node/1234/edit&breadcrumb=2
This is what it looks like as a masked, clean url:
http://www.mydomain.com/node/1234/edit&breadcrumb=2
If we make "&" into "?" then the querystring will break because php globals will see it as:
http://www.mydomain.com?q=node/1234/edit?breadcrumb=2
Even though with clean urls, it'll "look" like:
http://www.mydomain.com/node/1234/edit?breadcrumb=2