pcman-bbs / pcmanx

GTK version
GNU General Public License v2.0
79 stars 74 forks source link

Fix the code that incorrectly trim URL. #69

Closed sifmelcara closed 8 years ago

sifmelcara commented 8 years ago

url.find_first_not_of("telnet://") is wrong. Any prefix that contain characters in {'t', 'e', 'l', 'n', ':', '/'} will be removed. For example, "eod.tw" will be trimmed to "od.tw"

legnaleurc commented 8 years ago

IMHO std::string::find will be better.

    const string telnetPrefix = "telnet://";
    if (url.find(telnetPrefix) == 0)
        url.erase(0, telnetPrefix.size());
kidwm commented 8 years ago

@legnaleurc Nice shot! @sifmelcara how about you?

sifmelcara commented 8 years ago

I think substr() has better readability and speed(in worst case) in this case. However, I do not care things other than correctness much.

david50407 commented 6 years ago

When will this patch release? cc @kidwm

kidwm commented 6 years ago

I forgot to ask @fourdollars about this yesterday