Azure Jane Lunatic (Azz) 🌺 (
azurelunatic) wrote in
dw_dev2015-08-17 11:41 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[site community profile]](https://www.dreamwidth.org/img/comm_staff.png)
Entry tags:
I did it! I broke the site! ... just a little... with a little bit of WTF-8.
So if anyone who uses the Rich Text editor when posting an entry was trying to insert a link to a github user, and wondered why it didn't look like Github was in the list, when you could have sworn you'd seen it in a recent code tour...
... it isn't.
"Github" is not in that list.
"github", however, is. Lower-case. And since that list sorts capital letters first (all capitals before all lower-case, according to an ancient table), this means that "github" goes down to the bottom of the list, below YouTube.
In dw-free/cgi-bin/DW/External/Site/Github.pm
line 19 is:
package DW::External::Site::github;
Which ... I wrote! Hooray! (Oops.)
So how I came to discover it was like this.
In IRC,
sgsabbage was preparing a code tour.
03:53 AM < Azz> whee yay code tour
03:53 AM < Azz> which is not cod tour
03:53 AM < kaberett> no do not tour the cod
03:53 AM < kaberett> ... I might actually add that to the Book Of Wholesome Activities
03:53 AM * Azz snerk
03:54 AM * Azz decides against cod pieces for dinner later
03:54 AM < kaberett> I should presumably get rah to ban me from touring the cod before adding it to the page :-p
03:54 AM < kaberett> (sgs: http://wiki.dreamwidth.net/wiki/index.php/Book_of_Wholesome_Hobbies)
03:54 AM < sgsabbage> haha
03:54 AM < sgsabbage> um... why is the compose window throwing a fit at me_and's github username?
03:55 AM < sgsabbage> it keeps telling me 'unknown user or site'
03:55 AM < Azz> RTE? :\
03:55 AM < kaberett> it wants a hyphen
03:55 AM < kaberett> because fuck you github
03:55 AM < Azz> oh underscores
03:55 AM < sgsabbage> but it has a hyphen..
03:55 AM < kaberett> ...
03:55 AM < sgsabbage> maybe it's wrong kind of hyphen
03:56 AM < kaberett> copypasta the username code in here if retyping the hyphen don't fix it?
So collectively we tested exactly what sgsabbage had typed, in the beta update page, the HTML update page, and then in switching over to the Rich Text tab, there was the same error! One problem: github requires hyphens for those usernames who have them, and does not know what to do with underscores.
I tried to manually insert a github username. I looked for it on the list where you'd expect to see a G, but did not find it there. The list is a bit long. I didn't try scrolling up or scrolling down. I reported back in some alarm, fearing that I'd somehow managed to not get github into the list at all, and that was why the RTE was rejecting it.
Collectively, we determined that github usernames with underscores and github usernames without either underscores or hyphens worked just fine in the RTE. So it wasn't the (supposed) absence of github on the list that was the problem here.
But oh. Dreamwidth usernames have underscores. Most places on Dreamwidth are smart enough to accept either hyphens or underscores, and then Do The Right Thing, but the RTE has always been a bit delicate.
I contemplated asking someone to write a rule saying that Github usernames had to have hyphens if there was going to be something there, but then realized that just because we happened to know that Github uses hyphens, that's not necessarily going to work for all sites ever -- and what if Github changes things? Really, Dreamwidth shouldn't enforce a no-hyphens rule on anybody, as long as we're still good against user-entered garbage that might break a database. I filed an issue.
That still left the little matter of the missing Github on the list. I loaded it again, with the intent of plowing through Github and seeing what was in the code for the other sites that I'd missed for Github. I scrolled down the list -- and there I saw little lowercase github, curled at the bottom like a lonely baby chick huddled up in the corner of a cold cardboard box. Aww. Poor lil' thing.
Then I started giggling, because I knew exactly what had happened. I had forgotten to account for alphabetical-order-by-UTF-8. That error is precious to me because of this one time on LiveJournal, where I traced a "all the userpics in comments are being randomized!" complaint to the fact that one list of userpics had been sorted in latin true-alphabetical order, and another had been sorted in UTF-8 order. Then the position from the first list had been used to select the userpic from the second list. Items near the top and bottom of the list were sometimes the same, and the "wrong" userpic was always the same one, which was how I had come to suspect something.
So I filed another issue. I suspect that I'll work on it this weekend (unless someone else beats me to it, because I haven't claimed it, on purpose). I will have to change the capitalization on line 19, and I will have to search through to see that the capitalization is also changed in every other place that may happen to mention it.
... it isn't.
"Github" is not in that list.
"github", however, is. Lower-case. And since that list sorts capital letters first (all capitals before all lower-case, according to an ancient table), this means that "github" goes down to the bottom of the list, below YouTube.
In dw-free/cgi-bin/DW/External/Site/Github.pm
line 19 is:
package DW::External::Site::github;
Which ... I wrote! Hooray! (Oops.)
So how I came to discover it was like this.
In IRC,
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
03:53 AM < Azz> whee yay code tour
03:53 AM < Azz> which is not cod tour
03:53 AM < kaberett> no do not tour the cod
03:53 AM < kaberett> ... I might actually add that to the Book Of Wholesome Activities
03:53 AM * Azz snerk
03:54 AM * Azz decides against cod pieces for dinner later
03:54 AM < kaberett> I should presumably get rah to ban me from touring the cod before adding it to the page :-p
03:54 AM < kaberett> (sgs: http://wiki.dreamwidth.net/wiki/index.php/Book_of_Wholesome_Hobbies)
03:54 AM < sgsabbage> haha
03:54 AM < sgsabbage> um... why is the compose window throwing a fit at me_and's github username?
03:55 AM < sgsabbage> it keeps telling me 'unknown user or site'
03:55 AM < Azz> RTE? :\
03:55 AM < kaberett> it wants a hyphen
03:55 AM < kaberett> because fuck you github
03:55 AM < Azz> oh underscores
03:55 AM < sgsabbage> but it has a hyphen..
03:55 AM < kaberett> ...
03:55 AM < sgsabbage> maybe it's wrong kind of hyphen
03:56 AM < kaberett> copypasta the username code in here if retyping the hyphen don't fix it?
So collectively we tested exactly what sgsabbage had typed, in the beta update page, the HTML update page, and then in switching over to the Rich Text tab, there was the same error! One problem: github requires hyphens for those usernames who have them, and does not know what to do with underscores.
I tried to manually insert a github username. I looked for it on the list where you'd expect to see a G, but did not find it there. The list is a bit long. I didn't try scrolling up or scrolling down. I reported back in some alarm, fearing that I'd somehow managed to not get github into the list at all, and that was why the RTE was rejecting it.
Collectively, we determined that github usernames with underscores and github usernames without either underscores or hyphens worked just fine in the RTE. So it wasn't the (supposed) absence of github on the list that was the problem here.
But oh. Dreamwidth usernames have underscores. Most places on Dreamwidth are smart enough to accept either hyphens or underscores, and then Do The Right Thing, but the RTE has always been a bit delicate.
I contemplated asking someone to write a rule saying that Github usernames had to have hyphens if there was going to be something there, but then realized that just because we happened to know that Github uses hyphens, that's not necessarily going to work for all sites ever -- and what if Github changes things? Really, Dreamwidth shouldn't enforce a no-hyphens rule on anybody, as long as we're still good against user-entered garbage that might break a database. I filed an issue.
That still left the little matter of the missing Github on the list. I loaded it again, with the intent of plowing through Github and seeing what was in the code for the other sites that I'd missed for Github. I scrolled down the list -- and there I saw little lowercase github, curled at the bottom like a lonely baby chick huddled up in the corner of a cold cardboard box. Aww. Poor lil' thing.
Then I started giggling, because I knew exactly what had happened. I had forgotten to account for alphabetical-order-by-UTF-8. That error is precious to me because of this one time on LiveJournal, where I traced a "all the userpics in comments are being randomized!" complaint to the fact that one list of userpics had been sorted in latin true-alphabetical order, and another had been sorted in UTF-8 order. Then the position from the first list had been used to select the userpic from the second list. Items near the top and bottom of the list were sometimes the same, and the "wrong" userpic was always the same one, which was how I had come to suspect something.
So I filed another issue. I suspect that I'll work on it this weekend (unless someone else beats me to it, because I haven't claimed it, on purpose). I will have to change the capitalization on line 19, and I will have to search through to see that the capitalization is also changed in every other place that may happen to mention it.
no subject
:)
no subject
:D
no subject
no subject
no subject
no subject