Absolute links being converted into relative ones

Absolute links being converted into relative ones

by Zbigniew Fiedorowicz -
Number of replies: 16
When copying html text in the editor within Mozilla Firefox 1.0, all absolute links refering to the Moodle site running the server get converted into relative ones, when pasted from the Clipboard.  For example if I were to paste a url like
href="http://moodle.org/mod/glossary/...."
into this window, it will get converted into
href="../glossary/..."
This happens right after the paste operation.  When I switch to source mode, I see the relative urls in the window.  If I switch back to normal edit mode, copy the text from the window and paste into some other html editor (e.g. Mozilla Composer), the urls get restored back to absolute form.

This behavior doesn't happen when using other browsers, e.g. Internet Explorer or the original Mozilla browser.  The Firefox behavior causes significant problems, when posts are emailed out.  Not only are the relative links in the email dysfunctional, but in our email servers they trigger antispam alerts which are inserted into the body of the email, making it unreadable.  See the following discussion and bug tracker reference contained therein: http://moodle.org/mod/forum/discuss.php?d=22016
(Note: this link was inserted using the link tool, not via copy/paste.)

Janne, could you look into this and see if anything can be done about this?
Average of ratings: -
In reply to Zbigniew Fiedorowicz

Re: Absolute links being converted into relative ones

by Zbigniew Fiedorowicz -
This is definitely bad behavior in Firefox, not the fault of HTML Editor.  I tried the same experiment in gmail.com.  Pasting a link of the form
href="http://gmail.google.com/smail/excult.php"
into an outgoing email resulted in
href="../smail/excult.php"
appearing in the incoming mail, also triggering the spam alert from our mail server.


In reply to Zbigniew Fiedorowicz

Re: Absolute links being converted into relative ones

by Chardelle Busch -
Picture of Core developers
I'm glad you brought this up again, Zbigniew, cause I love Firefox, except for the cut and paste issue. Of course, this discussion covers the issue: http://moodle.org/mod/forum/discuss.php?d=5880, but the fix is in Firefox, not Moodle.

I think this might be a problem for users who want to cut and paste into posts from, for example Word. Firefox just won't let you do that (unless, of course, they toggle to html--but I don't want my users to have to mess with that). And, of course, even pasting into html doesn't solve the link problem.

So, anybody have any new thoughts about getting around the cut and paste issues in Firefox?
In reply to Chardelle Busch

Re: Absolute links being converted into relative ones

by Michael Penney -
Hmm, doesn't 'edit-copy' and 'edit-paste'   (from the edit menu dropdown) always work in Firefox?

Anyway, I think the best thing would be to complain to the firefox folks; this setting should be like pop-ups, active-x, etc. "allow script to copy and paste from this site"--No/Ok.

Pretty ridiculous that they expect users to hack around in config files to 'fix' this, IMO.
In reply to Michael Penney

Re: Absolute links being converted into relative ones

by Zbigniew Fiedorowicz -
It doesn't matter if you paste with cntl-V or from the Edit menu, your urls will get converted either way.
In reply to Michael Penney

Re: Absolute links being converted into relative ones

by Chardelle Busch -
Picture of Core developers
It does work from the Firefox Edit menu (except like Z mentions above), but you can't paste anything at all using the html editor's paste icon. So, it's some weird thing with Firefox and html editor--you're right Michael maybe somebody needs to ask Firefox for help on this.
In reply to Chardelle Busch

Re: Absolute links being converted into relative ones

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
No need to ask Firefox developers, there must be a way because copy/paste in TinyMCE works without any config hacks wink

skodak
In reply to Petr Skoda

Re: Absolute links being converted into relative ones

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Aahhh now that would be a very interesting development (the pasting I mean).  I see some a mention of the Firefox security in their forums though, so perhaps it's only because we've edited our user.js already?

But this topic is being hijacked, since the issue Zig is talking about is about what Firefox does to the pasted text. See bug 2953 ...
In reply to Petr Skoda

Re: Absolute links being converted into relative ones

by Zbigniew Fiedorowicz -
I would also like to point out that Petr's post
http://moodle.org/mod/forum/discuss.php?d=22013
is an example of this bug which brought this issue to my attention. If you look at the post, you will find all the autolink urls have been converted to relative links and the links in the resulting email are dysfunctional.  Petr must have editted his original post in Firefox, and in the process copied and pasted.

I have posted a bug on this at bugzilla.moodle.org: https://bugzilla.mozilla.org/show_bug.cgi?id=290740
and also posted to the Firefox support discussion board:
http://forums.mozillazine.org/viewtopic.php?p=1395170
In reply to Zbigniew Fiedorowicz

Re: Absolute links being converted into relative ones

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Hmmm, interesting I always hated the way HTMLA area works in Firefox (it always eats spaces in code blocks). When I need to edit my post, I usually copy the text to clipboard, then click edit link, paste text and only then start editing, off topic again...

Back to relative links: I have looked in TinyMCE source code and they have a hack to convert all relative links into absolute, IMHO we could do the same. It seems it is a Firefox feature, not a bug sad
In reply to Zbigniew Fiedorowicz

Re: Absolute links being converted into relative ones

by Zbigniew Fiedorowicz -
I just noticed that Firefox converts relative urls into absolute urls whenever you copy html text from a web page into some other html aware application.  So I guess the Firefox developers consider this behavior, and the reverse transformation in the other direction, to be a desirable feature.

While this may be useful in many circumstances, one can easily imagine circumstances where this is not what one wants.  Surely one would want some way of turning off this behavior.
In reply to Zbigniew Fiedorowicz

Re: Absolute links being converted into relative ones

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Have you had a look through your configuration in Firefox (go to URL about:config manually) for any likely variables? I couldn't see any ...

In reply to Martin Dougiamas

Re: Absolute links being converted into relative ones

by Zbigniew Fiedorowicz -
Nope, me neither.
In reply to Zbigniew Fiedorowicz

Re: Absolute links being converted into relative ones

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Hmm, I have changed line 2256 in htmlarea.php (version 1.48):
//value = a.nodeValue;
value = root[a.nodeName];

Now it seems, that the absolute links stay absolute, but I wonder what else was broken...

skodak

Off topic: I have found interesting site with HTML Area fork Xinha, the source code contains patch to enable Ctrl-V without hacking user.js smile
Average of ratings: Useful (1)
In reply to Petr Skoda

Re: Absolute links being converted into relative ones

by Chardelle Busch -
Picture of Core developers

Here's a discussion post at Mozilla about pasting URL's using Firefox, the guy was having a heck of a time getting Firefox support to understand the problem. Here is the last part of the post: "I would say that the problem happens not in the Paste operation, but during serialization, when the rich text field is turned into a stream of text before the message is sent." And the guy goes on to suggest posting a bug.

http://forums.mozillazine.org/viewtopic.php?t=252004&highlight=paste+editor

And if this helps, it isn't an "http" problem--it must have to do with href-- I once pasted an href with php code and it still cut it off?

In reply to Zbigniew Fiedorowicz

Re: Absolute links being converted into relative ones

by Janne Mikkonen -
This should work a ok in 1.5 dev...
although it'll need testing

- Janne -
In reply to Janne Mikkonen

Re: Absolute links being converted into relative ones when pasting into HTML editor in FF in Moodle 1.9.6

by Peter Evans -

FF 3.6.13 is still changing absolute links to a page within a Moodle site to relatively ones in Moodle 1.9.6 when text is pasted into a forum in that Moodle site.

This is VERY frustrating. So frustrating that I am changing my browser of choice to IE.

Peter Evans