diff --git a/ChangeLog b/ChangeLog index 3ed1ec6..f4081f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-09-23 Pierre-Luc Paour (1.5.1-b1) + + * Fixed getting album list and creating albums when the names + of albums contain non-ASCII characters (using UTF-8). + 2005-09-20 Pierre-Luc Paour (1.5) * Release. diff --git a/HTTPClient/HTTPResponse.java b/HTTPClient/HTTPResponse.java index 0579730..1388ab8 100644 --- a/HTTPClient/HTTPResponse.java +++ b/HTTPClient/HTTPResponse.java @@ -60,10 +60,10 @@ public class HTTPResponse implements HTTPClientModuleConstants private int timeout; /** the request */ - private Request request = null; + public Request request = null; /** the current response */ - Response response = null; + public Response response = null; /** the HttpOutputStream to synchronize on */ private HttpOutputStream out_stream = null; diff --git a/com/gallery/GalleryRemote/GalleryComm2.java b/com/gallery/GalleryRemote/GalleryComm2.java index 30062b5..052bf2b 100644 --- a/com/gallery/GalleryRemote/GalleryComm2.java +++ b/com/gallery/GalleryRemote/GalleryComm2.java @@ -977,6 +977,10 @@ void runTask() { boolean escapeCaptions = GalleryRemote._().properties.getBooleanProperty(HTML_ESCAPE_CAPTIONS); boolean utf8 = !escapeCaptions && parentAlbum.getGallery().galleryVersion == 2; + if (utf8) { + Log.log(Log.LEVEL_INFO, MODULE, "Will upload using UTF-8 for text data"); + } + // if the parent is null (top-level album), set the album name to an illegal name so it's set to null // by Gallery. Using an empty string doesn't work, because then the HTTP parameter is not // parsed, and the session album is kept the same as before (from the cookie). @@ -997,12 +1001,24 @@ void runTask() { new NVPair("newAlbumTitle", albumTitle, utf8?"UTF-8":null), new NVPair("newAlbumDesc", albumDesc, utf8?"UTF-8":null) }; - Log.log(Log.LEVEL_TRACE, MODULE, "new-album parameters: " + Arrays.asList(form_data)); form_data = fudgeFormParameters(form_data); - // load and validate the response - Properties p = requestResponse(form_data, su, this); + Log.log(Log.LEVEL_TRACE, MODULE, "new-album parameters: " + Arrays.asList(form_data)); + + Properties p = null; + if (utf8) { + // force using mime-multipart so we can use UTF-8 + NVPair[] hdrs = new NVPair[1]; + byte[] data = Codecs.mpFormDataEncode(form_data, new NVPair[0], hdrs); + + // load and validate the response + p = requestResponse(hdrs, data, g.getGalleryUrl(scriptName), true, su, this); + } else { + // normal request + p = requestResponse(form_data, su, this); + } + if (p.getProperty("status").equals(GR_STAT_SUCCESS)) { status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "crateAlbmOk")); newAlbumName = p.getProperty("album_name"); @@ -1334,6 +1350,8 @@ GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, b rsp = mConnection.Post(urlPath, data, form_data, new MyTransferListener(su)); } + //Log.log(Log.LEVEL_TRACE, MODULE, "Request body: " + new String(rsp.request.getData())); + // handle 30x redirects if (rsp.getStatusCode() >= 300 && rsp.getStatusCode() < 400) { // retry, the library will have fixed the URL @@ -1355,7 +1373,13 @@ GalleryProperties requestResponse(NVPair form_data[], byte[] data, URL galUrl, b throw new GR2Exception(GRI18n.getString(MODULE, "httpPostErr", params)); } else { // load response - String response = new String(rsp.getData()).trim(); + String response = null; + try { + response = new String(rsp.getText()).trim(); + } catch (ParseException e) { + Log.log(Log.LEVEL_ERROR, MODULE, "HTTPClient failed to parse response, getting data instead of text"); + response = new String(rsp.getData()).trim(); + } Log.log(Log.LEVEL_TRACE, MODULE, response); if (checkResult) { diff --git a/defaults.properties b/defaults.properties index acc1714..94f7561 100644 --- a/defaults.properties +++ b/defaults.properties @@ -245,6 +245,6 @@ updateUrlBeta=http://gallery.sourceforge.net/gallery_remote_version_check_beta.p # # --- Do not edit below this line --- # -version=1.5 -releaseDate=2005/09/20 +version=1.5.1-b1 +releaseDate=2005/09/23 aboutText=Gallery Remote\n \n \nA part of the Gallery Open-Source Project\nhttp://gallery.sourceforge.net\n \n \nMaintained by:\n \nPierre-Luc Paour\n \n \nInitial version by Chris Smith\n \n \nContributors:\n \nTim Miller\nDolan Halbrook\nMarkus Cozowicz\nScott Gartner\nAmedeo Paglione\nChris Schwerdt\nSeth Ladd\n \n \nArtwork by Ross A. Reyman\n \n \nBundled software:\n \nImageMagick\nJava look and feel Graphics Repository icons\njpegtran, Guido Vollbeding's version\nMetadataExtractor