Branch: Tag:

2001-04-05

2001-04-05 23:44:59 by Johan Sundström <oyasumi@gmail.com>

Should fix cimg bugs I introduced when trying to fix [bug 1411 (#1411)].
(Really a backport of Per's bugfix from 2.2.)

Rev: server/modules/graphics/cimg.pike:1.40

7:      roxen.ImageCache the_cache;    - constant cvs_version = "$Id: cimg.pike,v 1.39 2001/03/30 11:35:46 jhs Exp $"; + constant cvs_version = "$Id: cimg.pike,v 1.40 2001/04/05 23:44:59 jhs Exp $";   constant module_type = MODULE_TAG;   constant module_name = "Image converter";   constant module_doc = "Provides the tag <tt>&lt;cimg&gt;</tt> that can be used "
109:   ]);   #endif    + int do_ext; +    void create()   {    defvar("ext", Variable.Flag(0, VAR_MORE,
118:    "This is not necessary, but might seem "    "nicer, especially to people who try "    "to mirror your site.")); +  do_ext = query("ext");   }      void start()
149:      mapping find_internal( string f, RequestID id )   { -  if(strlen(f)>4 && query("ext") && f[-4]=='.') // Remove .ext -  f = f[..strlen(f)-5]; -  return the_cache->http_file_answer( f, id ); +  // It's not enough to +  // 1. Only do this check when the ext flag is set, old URLs might +  // live in caches +  // +  // 2. Check str[-4] for '.', consider .jpeg .tiff etc. +  // +  // However, . is not a valid character in the ID, so just cutting at +  // the first one works. +  return the_cache->http_file_answer( (f/".")[0], id );   }      mapping get_my_args( mapping args, RequestID id )
215:    catch // This code will fail if the image does not exist.    {    res->src = (query_internal_location()+the_cache->store( a,id )); -  if(query("ext")) +  if(do_ext)    res->src += "." + (a->format || "gif");    data = the_cache->data( a, id , 0 );    res["file-size"] = strlen(data);
244:    mapping a = get_my_args( check_args( args ), id );    args -= a;    string ext = ""; -  if(query("ext")) +  if(do_ext)    ext = "." + (a->format || "gif");    args->src = query_absolute_internal_location(id)    + the_cache->store( a, id ) + ext;
275:    {    result = query_absolute_internal_location(id)    + the_cache->store(get_my_args(check_args( args ), id ), id) -  + (query("ext") ? "" : "." + (args->format || "gif")); +  + (do_ext ? "" : "." + (args->format || "gif"));    return 0;    }    }   }