Browse files

Escape apostrophes (fixes #13)

  • Loading branch information...
1 parent 465e59c commit 20d4194d368c48b4f6668dc486ce249b1d8d7b65 @daleharvey committed Nov 26, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/erldocs_core.erl
View
9 src/erldocs_core.erl
@@ -188,6 +188,9 @@ index_ordering([Type, App, Mod, _Sum]) ->
sort_index(A, B) ->
index_ordering(A) =< index_ordering(B).
+html_encode(Str) ->
+ re:replace(Str, "'", "", [{return, list}, global]).
+
javascript_index(Conf, FIndex) ->
log("Creating erldocs_index.js ...~n"),
@@ -201,12 +204,12 @@ javascript_index(Conf, FIndex) ->
fun([A,B,C,[]]) ->
fmt("['~s','~s','~s',[]]", [A,B,C]);
([A,B,C,D]) ->
- fmt("['~s','~s','~s','~s']", [A,B,C,D])
+ fmt("['~s','~s','~s','~s']", [A,B,C,html_encode(D)])
end,
lists:sort(fun sort_index/2, lists:map(F, FIndex))),
- Js = re:replace(fmt("var index = [~s];", [string:join(Index, ",")]),
- "\\n|\\r", "", [{return,list}]),
+ Js = re:replace(fmt("var index = [~s];", [string:join(Index, ",")]),
+ "\\n|\\r", "", [{return,list}, global]),
ok = file:write_file([dest(Conf), "/erldocs_index.js"], Js).

0 comments on commit 20d4194

Please sign in to comment.