Anonymous avatar Anonymous committed 71cc61e

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

Comments (0)

Files changed (3)

apps/wriaki/src/article.erl

 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) ->

apps/wriaki/src/wiki_resource.erl

     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
     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,
     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},
                            [{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 ];
                 _ ->
                     []

apps/wriaki/templates/error_404.dtl

     <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%}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.