• ramble81@lemm.ee
    link
    fedilink
    arrow-up
    4
    arrow-down
    1
    ·
    2 hours ago

    I’ve always hated case sensitivity. I know that at an ASCII level “variable” != “Variable” but is there really a reason to have a distinction between them?

    • vithigar@lemmy.ca
      link
      fedilink
      arrow-up
      7
      ·
      2 hours ago

      You stated the reason yourself. Those are different values and matching in a case-insensitive manner is more work under the hood.

      • ramble81@lemm.ee
        link
        fedilink
        arrow-up
        5
        arrow-down
        2
        ·
        2 hours ago

        We do plenty of stuff for human consumption. Computers work for us, not the other way around. Insensitivity should be the default. It’s okay to give options. I’m not saying take that away.

        • calcopiritus@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          1 hour ago

          For some reason we decided that a lot of formats written by computers and read by computers would use ASCII encoding instead of raw data.

          Making a json or XML deserializer case insensitive would just make it slower for almost 0 benefit.

  • jjjalljs@ttrpg.network
    link
    fedilink
    arrow-up
    65
    arrow-down
    1
    ·
    8 hours ago

    Is the backend Python and the frontend JavaScript? Because then that would happen and just be normal, because Boolean true is True in python.

        • palordrolap@fedia.io
          link
          fedilink
          arrow-up
          1
          ·
          22 minutes ago

          In this instance, I think there was some suggestion to write code in mostly lower case, including all user variables, or at least inCamelCaseLikeThis with a leading lower case letter, and so to make True and False stand out, they’ve got to be capitalised.

          I mean. They could have been TRUE and FALSE. Would that have been preferable? Or how about a slightly more Pythonic style: __true__ and __false__

    • testfactor@lemmy.world
      link
      fedilink
      arrow-up
      91
      arrow-down
      1
      ·
      8 hours ago

      Probably, but if you’re interpreting user inputs as raw code, you’ve got much much worse problems going on, lol.

      • Given the warning about capitalization, the best possible case is that they’re using ast.literal_eval() rather than throwing untrusted input into eval().

        Err, I guess they might be comparing strings to ‘True’ and are choosing to be really strict about capitalization for some reason.

      • LostXOR@fedia.io
        link
        fedilink
        arrow-up
        21
        arrow-down
        1
        ·
        8 hours ago

        [...]&register=import os; os.system("sudo rm -rf /"); return True

        • MajorHavoc@programming.dev
          link
          fedilink
          arrow-up
          9
          ·
          6 hours ago

          Hey, that’s my username too. Or it was going to be, while the site was still up.

          What a coincidence!

          I guess I’ll wait for the site to come back, and see if it’s still available…

      • mmddmm@lemm.ee
        link
        fedilink
        arrow-up
        13
        arrow-down
        3
        ·
        8 hours ago

        It’s the settiings file… It’s probably supposed to only be written by the system admin.

        • raldone01@lemmy.world
          link
          fedilink
          arrow-up
          7
          arrow-down
          1
          ·
          edit-2
          6 hours ago

          A good place to put persistent malware. That’s why when using docker images always mount as ro if at all possible.

          • Ashley@lemmy.ca
            link
            fedilink
            arrow-up
            5
            ·
            7 hours ago

            It’s you can modify the settings file you sure as hell can put the malware anywhere you want

          • mmddmm@lemm.ee
            link
            fedilink
            arrow-up
            4
            ·
            7 hours ago

            Every environment has plenty of good places to put persistent malware. Even if you run your docker images as ro.

      • PotatoesFall@discuss.tchncs.de
        link
        fedilink
        arrow-up
        13
        ·
        7 hours ago

        Yep they should use a config file format like JSON or TOML or YAML or what have you, and then decode that into python objects. Using an actual programming language for config is dumb as hell IMO. (inb4 pissed off suckless fans)

      • jjjalljs@ttrpg.network
        link
        fedilink
        arrow-up
        4
        ·
        8 hours ago

        Depends on how it’s set up. If the setting is going into the env it’s a string, so I’d expect some sort of

        if os.getenv("this_variable", "false").lower() == "true":   # or maybe "in true, yes, on, 1" if you want to be weird like yaml
          this_variable = True
        else:
          this_variable = False
        

        Except maybe a little more elegant and not typed on my phone.

        But if the instructions are telling the user to edit the settings directly, like where I wrote this_variable=True, they’d need to case it correctly there.

  • lily33@lemm.ee
    link
    fedilink
    arrow-up
    6
    ·
    7 hours ago

    That makes me think, perhaps, you might be able to set it to exec("stuff") or True

    • MajorHavoc@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      6 hours ago

      I like your idea, but hear me out:

      A Python file for configuration is the best way to guarantee that any friendly code I write to help the user with config usually won’t execute. And I hate my users.