Permalink
Browse files

unquote search path so %20 and + lead to the same page title

  • Loading branch information...
Bryan Fink
Bryan Fink committed Oct 5, 2010
1 parent b084b39 commit 933b0f75b3d7378d5032e857bf92f09ca7a61e3f
Showing with 11 additions and 10 deletions.
  1. +6 −4 apps/wriaki/src/article.erl
  2. +4 −5 apps/wriaki/src/wiki_resource.erl
  3. +1 −1 apps/wriaki/templates/error_404.dtl
@@ -105,11 +105,13 @@ archive_key_part(ArchiveKey, Part) ->
url(Article) ->
case wobj:bucket(Article) of
?B_ARTICLE ->
- ["/wiki/",base64url:decode_to_string(wobj:key(Article))];
+ ["/wiki/",mochiweb_util:quote_plus(
+ base64url:decode_to_string(wobj:key(Article)))];
?B_ARCHIVE ->
- ["/wiki/",base64url:decode_to_string(
- article_key_from_archive_key(
- wobj:key(Article)))]
+ ["/wiki/",mochiweb_util:quote_plus(
+ base64url:decode_to_string(
+ article_key_from_archive_key(
+ wobj:key(Article))))]
end.
get_editor(Article) ->
@@ -209,7 +209,7 @@ in_mode(RD, ModeName) ->
wrq:get_qs_value(ModeName, RD) /= undefined.
search_path(RD) ->
- base64url:encode(wrq:disp_path(RD)).
+ base64url:encode(mochiweb_util:unquote(wrq:disp_path(RD))).
finish_request(RD, Ctx) ->
case wrq:response_code(RD) of
@@ -232,7 +232,7 @@ render_404_editor(RD, Ctx) ->
Article = article:create(search_path(RD),
list_to_binary(
[<<"= This page describes ">>,
- mochiweb_html:escape(mochiweb_util:unquote(base64url:decode_to_string(search_path(RD)))),
+ mochiweb_html:escape(base64url:decode_to_string(search_path(RD))),
<<" =\n">>]),
<<>>,
undefined,
@@ -242,7 +242,7 @@ render_404_editor(RD, Ctx) ->
to_html(RD, ACtx).
render_404(RD, Ctx) ->
- Search = mochiweb_util:unquote(base64url:decode_to_string(search_path(RD))),
+ Search = base64url:decode_to_string(search_path(RD)),
Results = search(Ctx#ctx.client, Search),
{ok, C} = error_404_dtl:render([{req, wrq_dtl_helper:new(RD)},
{search, Search},
@@ -267,8 +267,7 @@ search(Client, RawSearch) ->
[{map, {jsanon, ?SEARCH_FUN}, <<>>, true}]),
case RawResults of
[{0, RawKeys}] ->
- [ [{url, base64url:decode(R)},
- {title, mochiweb_util:unquote(base64url:decode(R))}]
+ [ [{title, base64url:decode(R)}]
|| R <- RawKeys ];
_ ->
[]
@@ -28,7 +28,7 @@
<h2>Perhaps you were looking for one of these pages?</h2>
<ul>
{% for result in results %}
- <li><a href="/wiki/{{result.url}}">{{result.title|escape}}</li>
+ <li><a href="/wiki/{{result.title|urlencode}}">{{result.title|escape}}</li>
{% endfor %}
</ul>
{% endif%}

0 comments on commit 933b0f7

Please sign in to comment.