Moodle
  1. Moodle
  2. MDL-12302

Issue with filter_save_ignore_tags missing empty html tags i.e. <a name="something"></a>

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.9.2
    • Component/s: Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      29870

      Description

      In some of our HTML content we have anchor links, unfortunately the regex that is built in filter_save_ignore_tags seems to have issues with empty tags.

      I believe this is because inside the tags it's doing (.+?) - Now I'm not a regex expert, actually far from it, but as far as I can tell that requires at least one char in between the open and closing tags.

      I've fixed this by changing (.+?) to (.*?) which seems to work in all cases.

      Could someone look over this fix, and if it's correct commit it to core.

      Thanks,

      James Brisland

        Activity

        Hide
        James Brisland added a comment -

        If you take the following HTML fragment and paste it into a HTML resource, then add the word "abroad" into the glossary and enable the auto glossary highlighting filter you will see with and without the fix the highlighting issues.

        ------------------------------------
        <div id="content">
        <table>
        <tbody>
        <tr>
        <td>
        <h2>1: National cultures</h2>

        <h2>1.2: Working abroad</h2>

        <p class="paradefault">The extract from a newspaper article in Example 1
        provides insight into the problems of working abroad.</p>

        <div class="activity">
        <a id="EXM004_001" name="EXM004_001"></a>

        <h3>Example 1</h3>

        <p class="paradefault">Working abroad is often considered the chance of a
        lifetime. Living and working in a foreign country with all expenses paid;
        what more could anyone want?</p>

        <p class="paradefault">In a surprising number of cases the answer is
        actually: ‘Quite a lot’. Finding yourself adrift in a
        different culture might seem exciting when you're on holiday, but it's an
        entirely different proposition when you're living and working. Codes of
        business practice may be radically different and the expatriate lifestyle
        can be lonely… yet many multinational companies have made little
        effort to prepare their employees for the shock.</p>

        <p class="paradefault">The advertising giant J Walter Thompson is a case
        in point. ‘We call in global relocation specialists to handle the
        practicalities of moving home and children's education,’ says a
        company spokesman. ‘But most other things we leave to the
        individual. The people we send abroad are experienced international
        businessmen and women and we expect them to understand different cultural
        milieus. There will always be the odd problem but we would hope that
        these could be dealt with by our local staff.’…</p>

        <p class="paradefault">But even with strong and knowledgeable support in
        the new country Chris Crosby, managing director of TMA, a company that
        specialises in corporate cross-cultural changes, believes more is
        required.</p>

        <p class="paradefault">‘Most people can identify explicit
        differences, such as clothing and food, which separate their culture from
        another and have little difficulty in adapting,’ he says.
        ‘More implicit differences are far harder to deal with. In the UK a
        business meeting is perceived as a place where a plan of action will be
        formulated and implemented. In other cultures, it is often just a forum
        for discussion. If you go abroad with the UK model as a preconception you
        might think that a meeting had been a disaster when it hadn't.’</p>

        <p class="paradefault">‘Rather than getting people to adopt a
        different culture than their own, you have to help them adapt their own
        style to a new culture. Critical to this is understanding one's own
        culture. Without examining our own underlying perceptions it is unlikely
        we will get to grips with another,’ Mr. Crosby says.</p>

        <p class="paradefault">But people are unpredictable and not all
        cross-cultural situations are cut and dried; many are ambiguous, so a key
        element of successful working practice is to concentrate on building
        relationships. ‘Your job is to do the right thing for the
        business,’ he says firmly. You need to be clear about
        non-negotiables, ethically and in terms of business
        operations.’</p>

        <div>
        (Source: Crace, 2000)
        </div>
        </div>

        <p class="paradefault">Hofstede's work has had a major influence on how we
        think about the cultures of businesses in different countries. We
        understand that people expect different things and operate in different
        ways in business and other organisations because of underlying societal
        values. Hofstede's work provides valuable insights into what we might
        expect when we do business in other places; this is important information
        in a world of increasing globalisation. Of course, there are always
        exceptions to the rule. Some businesses succeed because of their very
        ‘difference’: individuals are often attracted to work for
        businesses that seem ‘different’, and some customers prefer to
        shop there.</p>

        <div style="text-align:center">
        <a id="FIG001_I007" name="FIG001_I007"></a><img
        src="../../file.php/245/B120_1_I007i.jpg"
        alt="This is a cartoon image. It shows an office reception area. A receptionist stands behind a desk. A sign on the front of the desk reads ‘Non-Verbal Communications Incorporated’. A man and woman stand in front of the desk. The man is speaking to the woman. The caption of the cartoon reads. ‘See? That means, “What do you clowns want?”’" />

        <h3>‘See? That means "What do you clowns want?"’</h3>
        </div>

        <div class="activity">
        <a id="ACT004_002" name="ACT004_002"></a>

        <h3>Activity 2</h3>

        <p class="paradefault">You should allow 0 hour(s), 10 minute(s).</p>

        <p class="paradefault">Purpose: to reinforce understanding of culture in
        business.</p>

        <p class="paradefault">Task: can you think of any examples where a
        business you have worked for, or heard about, has tried to operate in a
        slightly different way from what you would expect? List any examples you
        can think of and make some notes on how it looked or felt different, and
        why.</p>

        <p class="paradefault"><a
        href="javascript:%20showcontent('DiscussionACT004_002')">Now read the
        discussion</a></p>

        <div class="activity" id="DiscussionACT004_002" style="display:none">
        <h3>Feedback</h3>

        <p class="paradefault">The examples we thought of were the small,
        low-cost airlines which began to undercut the prices and operations of
        the large national airlines in the 1990s. They changed the whole way in
        which people think about international travel and make travel
        arrangements. Another example is John Lewis, the UK retail group, which
        calls all its employees ‘partners’; all its employees have
        shares in the business.</p>

        <p class="paradefault">This simple exercise was intended to get you to
        think about the less obvious things that make a business
        ‘feel’ different, and why potential customers and employees
        may or may not be attracted to them.</p>
        </div>
        </div>

        <p class="paradefault">In the next section we begin to explore some
        academic definitions of this ‘slippery’ concept of culture at
        work.</p>
        </td>
        </tr>
        </tbody>
        </table>
        </div>
        ------------------------------------

        Show
        James Brisland added a comment - If you take the following HTML fragment and paste it into a HTML resource, then add the word "abroad" into the glossary and enable the auto glossary highlighting filter you will see with and without the fix the highlighting issues. ------------------------------------ <div id="content"> <table> <tbody> <tr> <td> <h2>1: National cultures</h2> <h2>1.2: Working abroad</h2> <p class="paradefault">The extract from a newspaper article in Example 1 provides insight into the problems of working abroad.</p> <div class="activity"> <a id="EXM004_001" name="EXM004_001"></a> <h3>Example 1</h3> <p class="paradefault">Working abroad is often considered the chance of a lifetime. Living and working in a foreign country with all expenses paid; what more could anyone want?</p> <p class="paradefault">In a surprising number of cases the answer is actually: ‘Quite a lot’. Finding yourself adrift in a different culture might seem exciting when you're on holiday, but it's an entirely different proposition when you're living and working. Codes of business practice may be radically different and the expatriate lifestyle can be lonely… yet many multinational companies have made little effort to prepare their employees for the shock.</p> <p class="paradefault">The advertising giant J Walter Thompson is a case in point. ‘We call in global relocation specialists to handle the practicalities of moving home and children's education,’ says a company spokesman. ‘But most other things we leave to the individual. The people we send abroad are experienced international businessmen and women and we expect them to understand different cultural milieus. There will always be the odd problem but we would hope that these could be dealt with by our local staff.’…</p> <p class="paradefault">But even with strong and knowledgeable support in the new country Chris Crosby, managing director of TMA, a company that specialises in corporate cross-cultural changes, believes more is required.</p> <p class="paradefault">‘Most people can identify explicit differences, such as clothing and food, which separate their culture from another and have little difficulty in adapting,’ he says. ‘More implicit differences are far harder to deal with. In the UK a business meeting is perceived as a place where a plan of action will be formulated and implemented. In other cultures, it is often just a forum for discussion. If you go abroad with the UK model as a preconception you might think that a meeting had been a disaster when it hadn't.’</p> <p class="paradefault">‘Rather than getting people to adopt a different culture than their own, you have to help them adapt their own style to a new culture. Critical to this is understanding one's own culture. Without examining our own underlying perceptions it is unlikely we will get to grips with another,’ Mr. Crosby says.</p> <p class="paradefault">But people are unpredictable and not all cross-cultural situations are cut and dried; many are ambiguous, so a key element of successful working practice is to concentrate on building relationships. ‘Your job is to do the right thing for the business,’ he says firmly. You need to be clear about non-negotiables, ethically and in terms of business operations.’</p> <div> (Source: Crace, 2000) </div> </div> <p class="paradefault">Hofstede's work has had a major influence on how we think about the cultures of businesses in different countries. We understand that people expect different things and operate in different ways in business and other organisations because of underlying societal values. Hofstede's work provides valuable insights into what we might expect when we do business in other places; this is important information in a world of increasing globalisation. Of course, there are always exceptions to the rule. Some businesses succeed because of their very ‘difference’: individuals are often attracted to work for businesses that seem ‘different’, and some customers prefer to shop there.</p> <div style="text-align:center"> <a id="FIG001_I007" name="FIG001_I007"></a><img src="../../file.php/245/B120_1_I007i.jpg" alt="This is a cartoon image. It shows an office reception area. A receptionist stands behind a desk. A sign on the front of the desk reads ‘Non-Verbal Communications Incorporated’. A man and woman stand in front of the desk. The man is speaking to the woman. The caption of the cartoon reads. ‘See? That means, “What do you clowns want?”’" /> <h3>‘See? That means "What do you clowns want?"’</h3> </div> <div class="activity"> <a id="ACT004_002" name="ACT004_002"></a> <h3>Activity 2</h3> <p class="paradefault">You should allow 0 hour(s), 10 minute(s).</p> <p class="paradefault">Purpose: to reinforce understanding of culture in business.</p> <p class="paradefault">Task: can you think of any examples where a business you have worked for, or heard about, has tried to operate in a slightly different way from what you would expect? List any examples you can think of and make some notes on how it looked or felt different, and why.</p> <p class="paradefault"><a href="javascript:%20showcontent('DiscussionACT004_002')">Now read the discussion</a></p> <div class="activity" id="DiscussionACT004_002" style="display:none"> <h3>Feedback</h3> <p class="paradefault">The examples we thought of were the small, low-cost airlines which began to undercut the prices and operations of the large national airlines in the 1990s. They changed the whole way in which people think about international travel and make travel arrangements. Another example is John Lewis, the UK retail group, which calls all its employees ‘partners’; all its employees have shares in the business.</p> <p class="paradefault">This simple exercise was intended to get you to think about the less obvious things that make a business ‘feel’ different, and why potential customers and employees may or may not be attracted to them.</p> </div> </div> <p class="paradefault">In the next section we begin to explore some academic definitions of this ‘slippery’ concept of culture at work.</p> </td> </tr> </tbody> </table> </div> ------------------------------------
        Hide
        Jenny Gray added a comment -

        James' fix has been working in the OU moodle for quite some time with no problems. This is a minor issue so I'm going to fix it the same way in core, because hopefully its had enough testing "in the wild".

        Show
        Jenny Gray added a comment - James' fix has been working in the OU moodle for quite some time with no problems. This is a minor issue so I'm going to fix it the same way in core, because hopefully its had enough testing "in the wild".
        Hide
        Dongsheng Cai added a comment -

        Verified, thanks

        Show
        Dongsheng Cai added a comment - Verified, thanks

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: