Question

Preface:

Im trying to create a firefox addon that will lookup a url with a post parameter in order to generate a link that i need to display in our case management software, but this will be later for now i just need to make the request.

This is the function i need to replicate: http://www.sdu.dk/servicenavigation/search/findperson/Lokale+Sogning

this is the url i need to look up: http://webhotel.sdu.dk/telefonbog/vejviser.php?isIFrame=yes

This is the room search for my University. our room a numbered like "V12-412a-1" these work fine but the ones thats start with "ø" (danish letter) dont work a room like "ø11-409-2"

This is my code for the request

var Request = require("sdk/request").Request;
var self = require("sdk/self");
var pm = require("sdk/page-mod").PageMod({
    include: "*.dk",
    contentScriptFile: self.data.url("contentscript.js"),
    onAttach: function(worker) {
        Request({
            url: "http://webhotel.sdu.dk/telefonbog/vejviser.php?isIFrame=yes",
        content: {nummer: "Ø11-409-2"},
            onComplete: function (response) {
                var parsed = (response);
                worker.port.emit('got-request', parsed);
        for (var headerName in response.headers) {
        console.log(headerName + " : " + response.headers[headerName]);
        }
            }
        }).post();
    }
});

The issue:

The request failed i think because the encoding or something like that i tried using javascripts encodeURIComponent() function does not fix the issue.

Do any of you guys have any clue why im not able to request anything from the page when the letter "ø" is in the request.

Please let me know if i can help with further information.

edit: spelling

Was it helpful?

Solution

The problem is that the server doesn't work with unicode but with some Danish 8-bit codepage. I say some because we, Greeks, have two major and a handful of minor 8-bit codepages.

It looks like escape() produces the "right" value for nummer.

content: {nummer: escape("Ø11-409-2")}

I'd recommend to add a comment in your code on exactly why escape is necessary. At a later point in time someone will check your code and will be tempted to replace it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top