X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Flib%2Fwikilib.ml;h=22f6506e090916a75973ae2613caeffb42e88f4c;hb=744ad347df455887349c683dd1c57af2b1ac0d28;hp=0ba0425b672dac781c1d5e3855750a604c4b0416;hpb=20923b33c08fccfca617b21935c4a4f6201593f8;p=cocanwiki.git diff --git a/scripts/lib/wikilib.ml b/scripts/lib/wikilib.ml index 0ba0425..22f6506 100644 --- a/scripts/lib/wikilib.ml +++ b/scripts/lib/wikilib.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: wikilib.ml,v 1.1 2004/10/21 11:42:05 rich Exp $ + * $Id: wikilib.ml,v 1.3 2004/11/01 16:24:50 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,6 +55,9 @@ let generate_url_of_title (dbh : Dbi.connection) hostid title = (* URL cannot begin with '_'. *) else if url.[0] = '_' then GenURL_BadURL + (* Titles which begin or end with spaces are probably mistakes. *) + else if isspace title.[0] || isspace title.[String.length title - 1] then + GenURL_BadURL else ( (* Check that the URL doesn't already exist in the database. If it does * then it probably means that another page exists with similar enough @@ -103,7 +106,7 @@ let markup_re = let link_re = Pcre.regexp "\\[\\[\\s*(.+?)\\s*(?:\\|(.+?)\\s*)?\\]\\]" let image_re = - Pcre.regexp "^(image|thumb(?:nail)?):\\s*([a-z0-9][_a-z0-9]*\\.(?:jpg|jpeg|gif|ico|png))$" + Pcre.regexp "^(image|thumb(?:nail)?):\\s*([a-z0-9][-._a-z0-9]*\\.(?:jpg|jpeg|gif|ico|png))$" let file_re = Pcre.regexp "^file:\\s*([a-z0-9][-._a-z0-9]*)$"