all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to escape a string which will be added as a ?key=value parameter in a url?
@ 2015-09-27 19:57 Marcin Borkowski
  2015-09-27 20:20 ` Michael Heerdegen
  2015-09-27 23:17 ` Emanuel Berg
  0 siblings, 2 replies; 9+ messages in thread
From: Marcin Borkowski @ 2015-09-27 19:57 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi all,

I have a bunch of keys and values, and I want to construct a url with
a ?key=value&key2=value2 syntax.  Is there a function which would
properly escape characters like ?, =, & for that?

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-27 19:57 How to escape a string which will be added as a ?key=value parameter in a url? Marcin Borkowski
@ 2015-09-27 20:20 ` Michael Heerdegen
  2015-09-28  0:45   ` Yuri Khan
  2015-09-27 23:17 ` Emanuel Berg
  1 sibling, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2015-09-27 20:20 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> I have a bunch of keys and values, and I want to construct a url with
> a ?key=value&key2=value2 syntax.  Is there a function which would
> properly escape characters like ?, =, & for that?

Maybe `url-hexify-string'?

Michael.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-27 19:57 How to escape a string which will be added as a ?key=value parameter in a url? Marcin Borkowski
  2015-09-27 20:20 ` Michael Heerdegen
@ 2015-09-27 23:17 ` Emanuel Berg
  1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2015-09-27 23:17 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> I have a bunch of keys and values, and I want to
> construct a url with a ?key=value&key2=value2
> syntax. Is there a function which would properly
> escape characters like ?, =, & for that?

Check out this file - there is a lot of
constructing/manipulating URLs for Google, TPB, YT,
Urban dictionary, wikis, and more:

    http://user.it.uu.se/~embe8573/conf/emacs-init/w3m/w3m-unisearch.el

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-27 20:20 ` Michael Heerdegen
@ 2015-09-28  0:45   ` Yuri Khan
  2015-09-29  0:47     ` Emanuel Berg
  0 siblings, 1 reply; 9+ messages in thread
From: Yuri Khan @ 2015-09-28  0:45 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs@gnu.org

On Mon, Sep 28, 2015 at 2:20 AM, Michael Heerdegen
<michael_heerdegen@web.de> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> I have a bunch of keys and values, and I want to construct a url with
>> a ?key=value&key2=value2 syntax.  Is there a function which would
>> properly escape characters like ?, =, & for that?
>
> Maybe `url-hexify-string'?

More like url-build-query-string.

Blindly substituting the value for %s in a format string, as Emanuel
suggests, is definitely not the right thing.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-28  0:45   ` Yuri Khan
@ 2015-09-29  0:47     ` Emanuel Berg
  2015-09-29  5:25       ` Yuri Khan
  2015-09-29  6:58       ` tomas
  0 siblings, 2 replies; 9+ messages in thread
From: Emanuel Berg @ 2015-09-29  0:47 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> Blindly substituting the value for %s in a format
> string, as Emanuel suggests, is definitely not the
> right thing.

Here is another example:

1. Load this file:

       http://user.it.uu.se/~embe8573/conf/emacs-init/isbn.el

2. Then, with the below Biblatex entry, put point at
   the beginning of the ISBN data field (i.e.,
   at/before the "0").

3. Do

       M-x isbn RET RET

...and observe what cool things you can do outside the
realm of schoolbook scholasticism!

@book{artificial-intelligence-and-the-design,
  title      = {Artificial Intelligence and the Design of Expert Systems},
  author     = {George Luger and William Stubblefield},
  publisher  = {Benjamin-Cummings},
  year       = 1989,
  ISBN       = 0805301399
}

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-29  0:47     ` Emanuel Berg
@ 2015-09-29  5:25       ` Yuri Khan
  2015-09-30  0:57         ` Emanuel Berg
  2015-09-29  6:58       ` tomas
  1 sibling, 1 reply; 9+ messages in thread
From: Yuri Khan @ 2015-09-29  5:25 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

On Tue, Sep 29, 2015 at 6:47 AM, Emanuel Berg <embe8573@student.uu.se> wrote:
> Yuri Khan <yuri.v.khan@gmail.com> writes:
>
>> Blindly substituting the value for %s in a format
>> string, as Emanuel suggests, is definitely not the
>> right thing.
>
> Here is another example:
>        http://user.it.uu.se/~embe8573/conf/emacs-init/isbn.el
>
> ...and observe what cool things you can do outside the
> realm of schoolbook scholasticism!

Look, Emanuel, we all know string concatenation works when you
absolutely know that your substituted values do not contain any funny
characters. Marcin specifically asked for a function that is robust in
presence of characters which are conventionally used as key/value/pair
separators in URI query strings.

See also a small excerpt from the biography of one boy named Robert:
https://xkcd.com/327/



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-29  0:47     ` Emanuel Berg
  2015-09-29  5:25       ` Yuri Khan
@ 2015-09-29  6:58       ` tomas
  2015-09-30  1:19         ` Emanuel Berg
  1 sibling, 1 reply; 9+ messages in thread
From: tomas @ 2015-09-29  6:58 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Sep 29, 2015 at 02:47:37AM +0200, Emanuel Berg wrote:

[...]

>        http://user.it.uu.se/~embe8573/conf/emacs-init/isbn.el

Nifty :-)

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlYKNnkACgkQBcgs9XrR2kafwgCePtPPYBbqUruFgEgU0RwhtqWF
YAkAn2vwOrx2i+hYRavI0p1OCfFD3nn6
=66B1
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-29  5:25       ` Yuri Khan
@ 2015-09-30  0:57         ` Emanuel Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2015-09-30  0:57 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> Look, Emanuel, we all know string concatenation
> works when you absolutely know that your substituted
> values do not contain any funny characters.

I also know that it works because I use those
functions every day.

> See also a small excerpt from the biography of one
> boy named Robert: https://xkcd.com/327/

OK, now I've read it. Seekwell injection joke. ":D"

Now, how about returning the favor by reading this?
It might affect your programming and life in a more
intellectual-emotional-physical way - compared to
xkcd, that is.

@book{metabarons,
  title      = {The Metabarons: Path of the Warrior},
  author     = {Alexandro Jodorowsky; Juan Gimenez},
  publisher  = {Humanoids},
  year       = 2002,
  ISBN       = {193065247X}
}

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to escape a string which will be added as a ?key=value parameter in a url?
  2015-09-29  6:58       ` tomas
@ 2015-09-30  1:19         ` Emanuel Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2015-09-30  1:19 UTC (permalink / raw)
  To: help-gnu-emacs

<tomas@tuxteam.de> writes:

>> http://user.it.uu.se/~embe8573/conf/emacs-init/isbn.el
>
> Nifty :-)

Ain't it the truth :)

Remember,

    Don't hate the interface,
    *become* the interface.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-09-30  1:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-27 19:57 How to escape a string which will be added as a ?key=value parameter in a url? Marcin Borkowski
2015-09-27 20:20 ` Michael Heerdegen
2015-09-28  0:45   ` Yuri Khan
2015-09-29  0:47     ` Emanuel Berg
2015-09-29  5:25       ` Yuri Khan
2015-09-30  0:57         ` Emanuel Berg
2015-09-29  6:58       ` tomas
2015-09-30  1:19         ` Emanuel Berg
2015-09-27 23:17 ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.