By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,573 Members | 3,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,573 IT Pros & Developers. It's quick & easy.

Spaces in parameter

P: n/a
I know it's terribly incorrect (well I think I know) to use something
like
<a href="bla.php?title=hello world">Hello World</a>
but can I safely do this?

I have an Apache Linux server with Blogger running, and I want to find
a way to make users go to my discussion forum, but to automatically
insert a link into the title of a new thread. Please see
<http://blog.outer-court.com> as an example, and when you click on
discuss you are taken to <http://blog.outer-court.com/forum/> which is
a PHP script.

I do not have any method (I believe) to let the pages be generated by
the Blogger template and include the title with correctly %20 encoded
spaces. I'm sure above will work in IExplorer as does many broken HTML.

Any help appreciated.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a

"Philipp Lenssen" <in**@outer-court.com> wrote in message
news:2j************@uni-berlin.de...
I know it's terribly incorrect (well I think I know) to use something
like
<a href="bla.php?title=hello world">Hello World</a>
but can I safely do this?

I have an Apache Linux server with Blogger running, and I want to find
a way to make users go to my discussion forum, but to automatically
insert a link into the title of a new thread. Please see
<http://blog.outer-court.com> as an example, and when you click on
discuss you are taken to <http://blog.outer-court.com/forum/> which is
a PHP script.

I do not have any method (I believe) to let the pages be generated by
the Blogger template and include the title with correctly %20 encoded
spaces. PHP certainly does have such a method, though I don't recall it offhand.
Seems like the kind of thing you would ask, though, in a PHP forum.
I'm sure above will work in IExplorer as does many broken HTML.


This isn't an HTML matter, it's about the URI standard.

Jul 20 '05 #2

P: n/a
Philipp Lenssen wrote:
I know it's terribly incorrect (well I think I know) to use something
like
<a href="bla.php?title=hello world">Hello World</a>
It's incorrect insofar as it's a violation of the spec.
but can I safely do this?


Dunno.

--
Jock
Jul 20 '05 #3

P: n/a
/Philipp Lenssen/:
I know it's terribly incorrect (well I think I know) to use something
like
<a href="bla.php?title=hello world">Hello World</a>
but can I safely do this?


A clever UA would automatically encode the spaces prior making the
request, but AFAIK it is not a requirement on its side, so if you
want to play it safe - just encode the specified text.

--
Stanimir
Jul 20 '05 #4

P: n/a
Philipp Lenssen wrote:
I know it's terribly incorrect (well I think I know) to use something
like
<a href="bla.php?title=hello world">Hello World</a>
but can I safely do this?

Because it's a URI, escape the space:
<a href="bla.php?title=hello%20world">Hello World</a>
or
<a href="bla.php?title=hello+world">Hello World</a>

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #5

P: n/a
James Moe wrote:
Philipp Lenssen wrote:
I know it's terribly incorrect (well I think I know) to use
something like
<a href="bla.php?title=hello world">Hello World</a>
but can I safely do this?

Because it's a URI, escape the space:
<a href="bla.php?title=hello%20world">Hello World</a>
or
<a href="bla.php?title=hello+world">Hello World</a>


I know I know -- like I said, I'm using Blogger.com and I don't believe
they handle this! All I can do is say:

<a href="[title]">...</a>...

Something along the lines.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #6

P: n/a
James Moe <jm***************@sohnen-moe.com> wrote:
Because it's a URI, escape the space:
<a href="bla.php?title=hello%20world">Hello World</a>
That's the correct URL encoded form.
or
<a href="bla.php?title=hello+world">Hello World</a>


That's not. You are confusing form data encoding with URL encoding.
When form data is encoded using the default encoding, a space _must_ be
replaced by the "+" character, and after that URL encoding is applied.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #7

P: n/a
Philipp Lenssen wrote:

Because it's a URI, escape the space:
<a href="bla.php?title=hello%20world">Hello World</a>


I know I know -- like I said, I'm using Blogger.com and I don't believe
they handle this!

Hm. That seems very un-standard of them. Have you tried it?

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #8

P: n/a
Jukka K. Korpela wrote:
James Moe <jm***************@sohnen-moe.com> wrote:
Because it's a URI, escape the space:
<a href="bla.php?title=hello%20world">Hello World</a>
That's the correct URL encoded form.


Right.

The preferred term in ur*@w3.org for such "escaping", or
"encoding", is now "percent-encoding", present in both the latest
IRI and URI drafts. Dehyphenate at your peril! ;o)
or
<a href="bla.php?title=hello+world">Hello World</a>


That's not.


Right.
You are confusing form data encoding with URL encoding.


Maybe. If so, I think it's understandable.

Going back to RFC1630 (informational), we see that "the plus sign
is reserved as shorthand notation for a space", in order "to make
query URIs easier to pass in systems which did not allow spaces";
but later, in RFC1738 (proposed standard), the same year, the
plus sign was removed from the set of reserved characters,
leaving it with no special significance. Now, however, RFC2396
has put the plus sign back into the query component's set of
reserved characters. Since RFC2396 updates the generic
definitions in RFC1738, the plus sign is currently reserved in
query components.

Is there anything wrong with <A href="?foo+bar">baz</A>? ISTM
the plus sign has its reserved "meaning" or "purpose" of a space.
It doesn't violate HTML or URI rules. Do some applications
interpret <A href="?foo%20bar">baz</A> differently?

Have a good weekend!

[ ... ]

--
Jock
Jul 20 '05 #9

P: n/a
John Dunlop <us*********@john.dunlop.name> wrote:
Jukka K. Korpela wrote:
James Moe <jm***************@sohnen-moe.com> wrote:
> Because it's a URI, escape the space: <a
> href="bla.php?title=hello%20world">Hello World</a>
That's the correct URL encoded form.


Right.

The preferred term in ur*@w3.org for such "escaping", or
"encoding", is now "percent-encoding", present in both the latest
IRI and URI drafts. Dehyphenate at your peril! ;o)


I usually don't bother too much using officialese, when the official
names are obscure, absurd, confusing, misleading, or just foolish, as
they often are. In this case, I don't bother at all, since "URL encoding"
is the term used in specifications, so the drafs need to achieve at least
RFC status before I let them confuse my language.
Going back to RFC1630 (informational), we see that "the plus sign
is reserved as shorthand notation for a space", in order "to make
query URIs easier to pass in systems which did not allow spaces";
That adhockery may have been associated with the way the <isindex>
element was defined, and still is. For input via that antique element,
browsers are required to map spaces to plus signs, presumably because it
was thought that this makes URLs more readable to human beings.
Since RFC2396 updates the generic
definitions in RFC1738, the plus sign is currently reserved in
query components.
But being reserved does not mean much; clause 2.2 in RFC 2396 says:
"Characters in the reserved set are not reserved in all contexts. The set
of characters actually reserved within any given URI component is defined
by that component. In general, a character is reserved if the semantics
of the URI changes if the character is replaced with its escaped US-ASCII
encoding."
The plus sign is declared reserved in a query component. So what?
This means that the semantics of a URL changes if a "+" sign in a query
part is replace by its URL encoded equivalent %2B. Programs that process
URLs, such as form handlers, may still treat them the same way if they
like.
Is there anything wrong with <A href="?foo+bar">baz</A>?
No, of course not. But the string after the "?" is just the query part,
to be handled by whichever program gets at it, the way it likes.
ISTM
the plus sign has its reserved "meaning" or "purpose" of a space.
No, it has no specific meaning or purpose defined in URL specifications.
It doesn't violate HTML or URI rules. Do some applications
interpret <A href="?foo%20bar">baz</A> differently?


Surely. There's no requirement that an application accept both and treat
them similarly. If you write a form handler, you can happily reject both,
since they cannot originate in an HTML form submission (without
interference). If you write an <isindex> handler, you are required to
accept the former but may well treat the latter an error, since it cannot
result from the use of <isindex> input.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #10

P: n/a
James Moe wrote:
Philipp Lenssen wrote:

Because it's a URI, escape the space:
<a href="bla.php?title=hello%20world">Hello World</a>


I know I know -- like I said, I'm using Blogger.com and I don't
believe they handle this!

Hm. That seems very un-standard of them. Have you tried it?


Actually they don't really know what they are doing when they replace
values in a template. Yes, I've tried it too. I don't even excpect them
to handle this.

Maybe I should have just written my own blogging software but when I
started out I first wanted to get a feeling for what blogging means and
what the application must have.
I think more and more about writing it myself in PHP+MySQL with
XHTML1.0 Strict+CSS2 output. I don't like most blogging apps as they
take too long to load and need JavaScript to work. Besides, Blogger.com
needs to transfer all files to my FTP server everytime, and if I change
the template I need to republish the whole blog (which is slow).

Thanks for the answers...

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.