Navigation Menu

Skip to content

Commit

Permalink
2005-09-23 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b1)
Browse files Browse the repository at this point in the history
	* Fixed getting album list and creating albums when the names
	  of albums contain non-ASCII characters (using UTF-8).
  • Loading branch information
Pierre-Luc Paour committed Sep 23, 2005
1 parent cb70377 commit dc29920
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2005-09-23 Pierre-Luc Paour <gallery@paour.com> (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 <gallery@paour.com> (1.5)

* Release.
Expand Down
4 changes: 2 additions & 2 deletions HTTPClient/HTTPResponse.java
Expand Up @@ -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;
Expand Down
32 changes: 28 additions & 4 deletions com/gallery/GalleryRemote/GalleryComm2.java
Expand Up @@ -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).
Expand All @@ -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");
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions defaults.properties
Expand Up @@ -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

0 comments on commit dc29920

Please sign in to comment.